Skip to content

XML External Entity (XXE) Vulnerability

Description

XML External Entity (XXE) attacks can occur when an XML parser supports XML entities while processing XML received from an untrusted source. This can lead to unauthorized access to sensitive data, denial of service, or other malicious activities.

Examples

Insecure Code

scala
val reader = XMLReaderFactory.createXMLReader
reader.parse(new InputSource(new StringReader(xmlString)))

Secure Code

scala
val reader = XMLReaderFactory.createXMLReader
reader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true)
reader.parse(new InputSource(new StringReader(xmlString)))

Remediation

Set the FEATURE_SECURE_PROCESSING feature to true on the XMLReader instance to prevent XXE attacks.

Rule Details

FieldValue
IDCODE-0091
CategoryInjection
SeverityMEDIUM
CWECWE-611
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
TagsXXE, XML Injection
OWASPN/A