My problem:
Fortify 4.2.1 is marking below code as susceptible for XML External Entities attack.
TransformerFactory factory = Transform
TransformerFactory trfactory = TransformerFactory.newInstance();
trfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
trfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
trfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
I think this would be sufficient.
Fortify would suggest below features but those doesn't work for TransformerFactory
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
We might need to change to a different parser to make use of them.