Skip to content

XMLInputFactory Misconfiguration

Description

XMLInputFactory used without disabling support for external entities or DTD access, which can lead to XXE (XML External Entity) vulnerabilities, exposing files, exfiltrating data, or allowing DoS attacks.

Examples

Insecure Code

java
XMLInputFactory factory = XMLInputFactory.newFactory();

Secure Code

java
XMLInputFactory factory = XMLInputFactory.newFactory();
factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
factory.setProperty("javax.xml.stream.isSupportingExternalEntities", false);

Remediation

Set ACCESS_EXTERNAL_DTD to "" and set javax.xml.stream.isSupportingExternalEntities to false

Rule Details

FieldValue
IDCODE-0766
CategoryInjection
SeverityMEDIUM
CWECWE-611
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
TagsXXE, XML External Entity
OWASPA05:2021-Security Misconfiguration