Play Framework セキュリティ勧告

XML外部エンティティ

日付

2013年9月20日

説明

PlayのXML処理に脆弱性が発見されました。

攻撃者はXML外部エンティティを使用して、ファイルシステムや内部ネットワークからファイルを読み取ったり、アプリケーションにDoS攻撃を仕掛けたりすることができます。

影響

デフォルトの全コンテンツパーサーまたは特にXMLパーサーを使用するアプリケーションは、脆弱な可能性があります。

影響を受けるバージョン

回避策

JDKで使用されるデフォルトのSAXParserFactory実装を外部エンティティを無効にする実装に変更します。

たとえば、Oracle JDKを使用している場合は、アプリケーションに次のクラスを追加します。

package xml;

import org.xml.sax.*;
import javax.xml.parsers.*;

public class SecureSAXParserFactory extends SAXParserFactory {
    private final SAXParserFactory platformDefault = new com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl();

    public SecureSAXParserFactory() throws SAXNotSupportedException, SAXNotRecognizedException, ParserConfigurationException {
        platformDefault.setFeature("http://xml.org/sax/features/external-general-entities", false);
        platformDefault.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
        platformDefault.setFeature("https://apache.dokyumento.jp/xml/features/disallow-doctype-decl", true);
    }

    public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
        return platformDefault.newSAXParser();
    }

    public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
        platformDefault.setFeature(name, value);
    }

    public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
        return platformDefault.getFeature(name);
    }
}

次に、本番モードでアプリケーションを起動するときに、次のシステムプロパティをコマンドライン引数に追加します。

-Djavax.xml.parsers.SAXParserFactory=xml.SecureSAXParserFactory

修正

下記の適切なバージョンにアップグレードします

CVSSメトリクス(詳細)

謝辞

この脆弱性の発見の功績は、Australia Post Digital Mailbox Security Teamとhttp://www.ubercomp.com/のReginaldo Silvaに行きました。