Skip to content

Commit 861f30c

Browse files
hotcodemachaAshutosh Gupta
authored andcommitted
CDPD-46149: HDFS-16766. XML External Entity (XXE) attacks can occur while processing XML received from an untrusted source (apache#4886)
Co-authored-by: Ashutosh Gupta <[email protected]> Signed-off-by: Akira Ajisaka <[email protected]> Change-Id: Id3fc0d9efa49810965c29ceebb2b6f193fc44c52 (cherry picked from commit c55d1a5)
1 parent d3db76a commit 861f30c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

  • hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ private List<ErasureCodingPolicy> loadECPolicies(File policyFile)
8989
// Read and parse the EC policy file.
9090
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
9191
dbf.setIgnoringComments(true);
92+
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
93+
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
94+
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
95+
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
96+
dbf.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", false);
9297
DocumentBuilder builder = dbf.newDocumentBuilder();
9398
Document doc = builder.parse(policyFile);
9499
Element root = doc.getDocumentElement();

0 commit comments

Comments
 (0)