Skip to content

Commit 697cae8

Browse files
hotcodemachaAshutosh Gupta
authored andcommitted
HDFS-16766. XML External Entity (XXE) attacks can occur while processing XML received from an untrusted source (#4886)
Co-authored-by: Ashutosh Gupta <[email protected]> Signed-off-by: Akira Ajisaka <[email protected]> (cherry picked from commit d9f435f)
1 parent eb230d5 commit 697cae8

File tree

1 file changed

+5
-0
lines changed
  • hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util

1 file changed

+5
-0
lines changed

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)