Skip to content

Commit 55a3b6c

Browse files
committed
Minor fix to BenchmarkScore to make XXE defense not break parsing of some XML docs.
1 parent e9bbcd8 commit 55a3b6c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/owasp/benchmark/score/BenchmarkScore.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,11 @@ private static void updateMenuTemplates( String toolmenu, String vulnmenu ) {
12681268

12691269
private static Document getXMLDocument( File f ) throws Exception {
12701270
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
1271-
// Prevent XXE
1272-
docBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
1271+
// Prevent XXE = Note, disabling this entirely breaks the parsing of some XML files, like a Burp results
1272+
// file, so have to use the alternate defense.
1273+
//dbFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
1274+
docBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
1275+
docBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
12731276
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
12741277
InputSource is = new InputSource(new FileInputStream(f));
12751278
Document doc = docBuilder.parse(is);

0 commit comments

Comments
 (0)