Knowledge Base · general

XXE

generaltechnique notetechniquexxe

XML External Entity injection: an XML parser resolves attacker-controlled external entities, enabling file disclosure and SSRF.

How it works

  • Untrusted XML is parsed with DTD processing enabled.
  • Define <!ENTITY xxe SYSTEM "file:///etc/passwd"> and reference &xxe; in the document.
  • Directory listing, jar:file:///app.jar!/ and /proc/self/cwd reads help fingerprint the backend.

Detection & defence

  • Disable DTDs / external entities (disallow-doctype-decl, external-general-entities=false, XMLConstants.ACCESS_EXTERNAL_DTD="").
  • Prefer JSON over XML for new APIs; run the XML parser with least privilege.