JAVA-030 / Advanced
Allowing XML external entities (XXE)
Why is this a problem?
Reading file:///etc/passwd and SSRF.
How to fix it
java
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
f.setFeature("https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html", true);
f.setFeature("https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html", false);
f.setFeature("https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html", false);
f.setXIncludeAware(false); f.setExpandEntityReferences(false);