Skip to content

Commit

Permalink
added fix for xml parser vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
Banji Jolaoso committed Dec 2, 2022
1 parent ba4a3ae commit 7017568
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private static List<Region> internalParse(
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setXIncludeAware(false);
factory.setExpandEntityReferences(false);
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
document = documentBuilder.parse(input);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private static DocumentBuilderFactory getDocumentBuilderFactory() {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
dbf.setXIncludeAware(false); // Default false for java 8. Disable XML Inclusions leading to SSRF - https://portswigger.net/web-security/xxe/lab-xinclude-attack
dbf.setExpandEntityReferences(false);
return dbf;
}
catch (ParserConfigurationException exception){
Expand Down

0 comments on commit 7017568

Please sign in to comment.