Skip to content

Improper Restriction of XML External Entity Reference ('XXE')

Description

External XML entities can be abused to read files, communicate with external hosts, exfiltrate data, or cause a Denial of Service (DoS). XML parsers and document loaders must be configured to not resolve entities.

Examples

Insecure Code

c#
var settings = new XmlReaderSettings(); settings.ProhibitDtd = false; XmlReader reader = XmlReader.Create(path, settings);

Secure Code

c#
var settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Prohibit; XmlReader reader = XmlReader.Create(path, settings);

Remediation

Set `XmlReaderSettings` `DtdProcessing` to `DtdProcessing.Prohibit` or ensure .NET Framework version is greater than 4.5.2

Rule Details

FieldValue
IDCODE-0454
CategoryInjection
SeverityMEDIUM
CWECWE-611
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
TagsXXE, XML External Entity
OWASPA1:2017-Injection, A03:2021-Injection