All vulnerabilities
CRITICALAppSecexploited in the wild

APPSEC-XXE

Web app · XML External Entity injection

Summary

XML External Entity (XXE) injection occurs when an application parses attacker-controlled XML with a parser that resolves external entities and DTDs, an unsafe default in many libraries such as Java's DocumentBuilderFactory, PHP's libxml, and .NET's XmlDocument. By declaring a DOCTYPE with an external entity such as one pointing at file:///etc/passwd and referencing it in the document body, the parser dereferences the URI and embeds the result into the parsed output, letting an attacker read local files, perform SSRF against internal services via http entities, or trigger denial of service through recursive entity expansion (the 'billion laughs' attack). In November 2013 Reginaldo Silva reported an XXE in Facebook's OpenID/Drupal handler that returned the contents of /etc/passwd and was treated as a path to remote code execution; Facebook patched it within hours and paid a then-record $33,500 bounty (disclosed January 2014). This class falls under OWASP A05:2021 Security Misconfiguration, which explicitly maps CWE-611.

How to avoid it in your code

  • Disable DOCTYPE and external entity resolution on every parser (e.g. setFeature disallow-doctype-decl true).
  • Set secure-processing and disable external-general-entities and external-parameter-entities.
  • Prefer non-validating parsers or formats like JSON when XML is not required.
  • Disable entity expansion or cap expansion limits to block billion-laughs DoS.
  • Run parsing with least privilege and egress filtering to blunt file-read and SSRF impact.

References

Related vulnerabilities

All AppSec →