
PRao202011 (Community Member) asked a question.
Veracode static scan showing two flows as CWE 611 XXE vulnerability in the app. We are doing Java xml parsing using DocumentBuilderFactory and xslt tranfformation using TransformerFactory.
I have set the Features according to OWASP/CheatSheetSeries for DocumentBuilderFactory as below:
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
documentBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
documentBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
And also for TransformerFactory as below:
TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
But still it is showing in static scan. Need help on this
.png)
Hi @PRao202011 (Community Member) ,
Veracode Static Analysis supports the remediation advice from the OWASP CheatSheet ( https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html ) and it will attempt to detect correct remediation of CWE 611 and automatically close the flaw.
It may however, not always be able to pick it up, especially if it is implemented in another method than the method doing the XML parsing.
We recommend moving the remediation to the method doing the XML parsing to have Veracode Static Analysis be able to detect it and automatically close the flaw or you can consider proposing a mitigation and contacting your security team to have it reviewed. For more information on how to propose a mitigation please see: https://help.veracode.com/reader/DGHxSJy3Gn3gtuSIN2jkRQ/~p4MSKOS8F8X8h0KwFTKoQ .
Thank you,
Boy Baukema