DocumentBuilderFactory is insecurely configured, which makes it susceptible to XXE attacks.
- Read confidential information.
- Execute commands on the server.
Securely configure DocumentBuilderFactory.
Authorized attacker from the Internet.
⌚ 30 minutes.
Default score using CVSS 3.1. It may change depending on the context of the src.
Default score using CVSS 4.0. It may change depending on the context of the src.
There are additional settings in the DocumentBuilderFactory to securely configure the service
import com.sap.security.hardener.nw.facade.HardenerFacade;
public static DocumentBuilderFactory secureDocumentBuilderFactory(final DocumentBuilderFactory factory, final String callerNamespace) throws ParserConfigurationException{
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
//One possible method to secure the DocumentBuildeerFactory
dbFactory = HardenerFacade.secureDocumentBuilderFactory(dbFactory);
DocumentBuilder parser = dbf.newDocumentBuilder();
parser.setErrorHandler(handler);
return parser.parse(stream);
}
The DocumentBuilderFactory does not have a secure configuration
public static DocumentBuilderFactory secureDocumentBuilderFactory(final DocumentBuilderFactory factory, final String callerNamespace) throws ParserConfigurationException{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder parser = dbf.newDocumentBuilder();
parser.setErrorHandler(handler);
return parser.parse(stream);
}