XML External Entity Injection

An XML processor that resolves externally-defined entities or DTDs from attacker-influenced input, turning a parser into a file-read, SSRF and data-exfiltration primitive (CWE-611).

What it is

XML lets a document declare entities — named placeholders — in a Document Type Definition (DTD). An entity declared with the SYSTEM keyword takes its value from an external resource: a file:// path, an http:// URL, or any URI scheme the parser’s resolver supports. When a parser resolves such an entity against untrusted input and the application returns, logs, or acts on the parsed result, the attacker reads local files, forces the server to issue requests, or exhausts resources. The trust boundary that breaks is simple and recurring: the dangerous behavior is a parser default, not an application mistake. Cisco’s own BroadWorks root-cause statement — “external entity resolution being allowed by default” — is the whole class in one line (Parsers Should Not Fetch Files).

Two entity kinds matter. General entities (&x;) substitute into the document body and surface in the parsed result. Parameter entities (%x;), usable only inside the DTD, can build further declarations and are the engine of nearly every blind, out-of-band and error-based technique (XXE as a DAST Finding, What is a Blind XXE Attack?).

Why it matters

XXE is a confidentiality-first bug that keeps escalating:

  • Arbitrary local file read — /etc/passwd, app config, private keys, session stores, readable by the service account.
  • SSRF → internal service reconnaissance, port scanning, and cloud instance-metadata credential theft (see XXE to SSRF and Cloud Metadata).
  • Remote code execution in specific stacks: PHP expect://, chaining to deserialization (ManageEngine ADAudit Plus), or unsafe XSLT.
  • Denial of service via entity expansion (billion laughs / XEE, CWE-776), independent of external resolution.

Severity drivers: pre-auth reachability (the parser runs before any login — SAML consumers, SOAP endpoints, provisioning protocols), what the service account can read, and egress/metadata exposure. A “limited” file read routinely escalates: one researcher took a read-only XXE from a $1,000 to a $10,000 bounty by pivoting through SSRF to an unauthenticated internal Redis session store via gopher:// (Limited XXE to Critical Redis Exposure). Real breaches: Cisco BroadWorks (CVE-2026-20320) was added to CISA KEV and used in “Operation Snowball” to steal a system-identity private key for lateral movement (CISA KEV Cisco BroadWorks); Apache Tika CVE-2025-66516 (CVSS 10.0) saw 500+ vulnerable instances mass-scanned (Critical Apache Tika CVE-2025-66516).

How it works

The mechanism splits into two halves, and most false-positive findings prove only the first: (1) a DOCTYPE is processed and internal entities expand; (2) an external reference is actually resolved. Most modern parsers in their default configuration will parse a DOCTYPE yet refuse external resolution, so confirmation must show the second half (XXE as a DAST Finding).

Variants, each with a dedicated page:

  • Classic in-band — a general external entity substitutes a file’s contents into a reflected field. Limited: aborts on files containing <, & or newlines, since those break the enclosing document.
  • Blind XXE — no reflection; detect and exfiltrate out-of-band via parameter entities and an attacker-hosted external DTD (DNS/HTTP/FTP callbacks).
  • Error-Based XXE — steer the parser into an exception whose message carries the file contents; works with zero out-of-band infrastructure, and has a local-DTD variant for fully internal networks.
  • XXE via File Uploads — the XML sink is hidden inside SVG, DOCX/XLSX/PPTX (OOXML is a ZIP of XML), PDF/XFA, SAML, GPX, WAV iXML, or RSS/Atom.
  • XInclude Attacks — when you control only one data value inside a server-built document and cannot add a DOCTYPE.
  • XXE to SSRF and Cloud Metadata — repurpose the resolver as a request engine against internal hosts and 169.254.169.254.

Where to find it

XXE lives anywhere XML is parsed, which is far wider than obvious application/xml bodies:

  • Content-Type pivot — endpoints documented as JSON often still parse XML when you flip Content-Type to application/xml/text/xml; a verbose parse error on the flipped request is the tell (Hunting in the Dark - Blind XXE, From Blind XXE to Root-Level File Read).
  • SOAP / WSDL / XML-RPC services and their imported schemas (Akamai CloudTest CVE-2025-49493, Axis2 WSDL/XSD XXE).
  • SAML assertion consumers — unauthenticated by nature, high-value.
  • File-upload parsers — SVG rasterizers, spreadsheet/document importers, PDF text extractors (Tika), media metadata.
  • Unusual HTTP methods — LOCK, PROPFIND and other WebDAV verbs accept XML bodies (OOB XXE via HTTP LOCK).
  • Library code paths that build their own parser — integration frameworks and XPath/XSLT helpers (Apache Camel documentType=InputSource) (Camel CVE-2026-85250).
  • Build and test tooling — rule-test XML in CI, where output lands in public build logs (PMD) (PMD).
  • Config/manifest/update importers and feed readers that parse network responses (XXE in update manifests).

Framework/parser hot spots and their defaults are catalogued in XXE Parser Defaults and Hardening.

How to test

  1. Confirm XML is parsed. Submit a well-formed minimal document; a different response or an XML parse error confirms a parser is present. Flip Content-Type on JSON endpoints.
  2. Confirm DOCTYPE processing. Define an internal general entity and reference it; if its value expands in the response, the DOCTYPE is processed. If even internal entities don’t expand, deprioritize (Limited XXE to Critical Redis).
  3. Try an in-band external read of a known, plain-text, no-metacharacter file you could recognize but not guess (/etc/hostname, Windows win.ini). Contents returning proves both halves.
  4. If blind, move to out-of-band: parameter entity + attacker-hosted external DTD to a Collaborator/Interactsh host. Watch for DNS-only vs full HTTP (DNS-only may be a firewall or a validator, not a complete channel) (Blind XXE, Out-of-Band Detection).
  5. If OOB is blocked, try error-based (parser-exception leakage) and the local-DTD variant (Error-Based XXE).
  6. Escalate to SSRF/metadata and internal services (XXE to SSRF and Cloud Metadata).

Triage checklist (separate the two halves, name the evidence class):

  • Is a DOCTYPE processed, or only an external reference actually resolved? Rate from the second.
  • Evidence class named: in-band / error-based / out-of-band / expansion.
  • In-band content is real file data carrying a value the scanner couldn’t know — not the payload or SYSTEM URI reflected back.
  • In-band failure may be a false negative: target file had XML metacharacters, or the bug is blind. Re-test with error-based/OOB before marking clean.
  • Office/SVG/SAML uploads and alternate content types tested, not just the obvious XML body.

Exploitation and escalation

Bypassing defenses

  • WAF / DOCTYPE filters: omit the XML declaration; add a space before the protocol (" file://"); alternate encodings — a filter checking only UTF-8/UTF-7 is defeated by UTF-16 (Meters Flag UTF-16 Bypass, Spilling Local Files via XXE). Hiding the DOCTYPE inside OOXML parts slips past WAFs that only see the multipart envelope (XXE Hidden in Cell A2).
  • Partial parser hardening: a parser that blocks external general entities may still resolve external parameter entities and external DTD subsets — Apache Roller’s setExpandEntityReferences(false) left exactly that gap (Apache Roller AtomPub XXE). Scanner-style denylist fixes get bypassed by escape sequences and double-encoding (PhpSpreadsheet ISO-2022 and unentity() TOCTOU) (PhpSpreadsheet ISO-2022 Bypass).
  • Hardening applied to one path only: Camel hardened its default document type but InputSource routed to a JDK-default parser; lxml hardened its main parsers in 5.0 but not iterparse()/ETCompatXMLParser() until 6.1 (Camel, lxml).
  • No DOCTYPE allowed: switch to XInclude Attacks, which need no DOCTYPE.
  • Egress blocked: Error-Based XXE (parser-error channel; local-DTD redefinition) needs no outbound reachability.
  • Parser-specific pitfalls and version defaults: XXE Parser Defaults and Hardening.

Real-world cases

  • CVE-2026-20320 — Cisco BroadWorks — unauth XXE in the OCI XML parser; CISA KEV, used in “Operation Snowball” to steal a system-identity private key (Cisco BroadWorks XXE).
  • CVE-2025-66516 — Apache Tika — CVSS 10.0, XFA form in a PDF; patch-miss expanding CVE-2025-54988; 500+ instances mass-scanned (Apache Tika XXE).
  • CVE-2026-125883 — N-able N-central — unauth, CISA KEV; part of the “Able2Shell” XXE-to-RCE chain requiring no credentials (Able2Shell FAQ). The XXE sits in service import; the chain steals a trusted local session, resets a password (or creates an enabled Default Administrator) and runs commands as nable. It was one of 33 AI-assisted zero-days published with PoCs without coordination, and N-able took hosted N-central offline worldwide. RMM makes the blast radius every managed endpoint (BleepingComputer, Field Effect).
  • CVE-2026-82171 — Dell PowerStore (8.0) — high-privileged XXE to sensitive file disclosure and root compromise of the appliance (notcve); CVE-2026-132241 — JetBrains TeamCity (7.3, PR:L/UI:R) — XXE in .NET build-step auto-discovery, fixed 2026.1.3 / 2025.11.7 (Rapid7); CVE-2026-17323 — IBM API Connect 12.1.0.0–12.1.1.2 — remote information disclosure, no vendor patch listed at the time (tsecurity).
  • CVE-2025-30220 / CVE-2025-58360 — GeoServer WFS/WMS — unauth, via GeoTools in-memory XSD schema building bypassing entity controls (GeoServer WFS XXE).
  • CVE-2025-49493 — Akamai CloudTest — SOAP RepositoryService, error-based + external DTD, found autonomously by XBOW (Akamai CloudTest).
  • CVE-2021-29447 — WordPress — low-priv author uploads a crafted WAV; iXML metadata chunk carries the XXE (WordPress WAV XXE).
  • CVE-2022-28219 — ManageEngine ADAudit Plus — blind XXE plants a ysoserial .jar, chained to Java deserialization for RCE (Rapid7 Analysis).
  • CVE-2025-54254 — Adobe Experience Manager Forms — unauth arbitrary file read (AEM Forms XXE).
  • CVE-2025-6984 — langchain-community — insecure etree.iterparse() (langchain-community XXE); CVE-2026-45071 — Symfony Config — XmlUtils::parse() with validateOnParse=true (Symfony Config XXE).
  • CVE-2026-92185 — Quest Foglight (unauth, SYSTEM context), CVE-2026-13289 — IBM MQ, CVE-2025-68493 — Apache Struts XWork, CVE-2025-27136 — LocalS3, CVE-2026-118975 — Telerik Reporting (SVG), CVE-2025-11035 — Jinher OA — a representative 2025–2026 CVE spread across enterprise middleware (Quest Foglight, Apache Struts, LocalS3).
  • CVE-2026-85250 — Apache Camel — XPath InputSource path bypassed default DTD hardening; file read and SSRF from the Camel process (Apache Camel).
  • CVE-2026-123029 — Wowza Streaming Engine ≤4.12.1 — critical, remote clients force local file reads with WSE’s privileges; interim mitigations: non-root service accounts, emptying deprecated remote shared object access (SharedObjectReadAccess/SharedObjectWriteAccess) in Application.xml, firewalling (Wowza).
  • DSA-2026-022 — Dataiku DSS — authenticated arbitrary file read (8.8), fixed 14.7.7 / 15.2.2 (Dataiku).
  • GHSA-vfmq-68hx-4jfw — lxml <6.1 — default iterparse()/ETCompatXMLParser() read local files (lxml).
  • GHSA-9hm5-r2r7-hjcq — PMD — rule-test XML exfiltrates CI files via test names in build logs (PMD).
  • Bug bounty classics: RunKeeper GPX upload (h3xStream RunKeeper), Bol.com seller-portal XLSX (XXE at Bol.com), and the “Top 25 XXE reports” roundup (Top 25 XXE Bug Bounty Reports).

Prevention

The single principle, from the OWASP cheat sheet: disable DTDs entirely on every parser that reads untrusted XML; reject documents containing a DOCTYPE (OWASP XXE Prevention Cheat Sheet).

  • If DTDs are genuinely required, disable external general entities, external parameter entities, and external DTD loading, and bound entity expansion and document size.
  • Keep XInclude off — it loads resources independently of DTDs.
  • Fail closed: if a parser doesn’t support a security setting, stop — do not parse partly hardened.
  • Restrict external access during schema validation and XSLT too (ACCESS_EXTERNAL_DTD/ACCESS_EXTERNAL_SCHEMA/ACCESS_EXTERNAL_STYLESHEET set to empty string in Java), not just the main parse.
  • Apply the same hardened factory everywhere — one forgotten DocumentBuilder in a utility class undoes the rest. Check every option that changes the input type or parser (Camel documentType), and set lxml resolve_entities explicitly rather than trusting version defaults.
  • Run XML-consuming services as unprivileged users so a file read is bounded by what that account can see (Wowza’s interim guidance).
  • Don’t rely on XSD validation or WAF signatures; entities resolve while the document is read.
  • Architecture: egress-filter the parsing host, enforce IMDSv2, run parsers as low-privilege accounts, and treat any secret readable on an exposed host as compromised after exposure (rotate keys rather than prove they weren’t copied).
    Per-language parser settings and defaults: XXE Parser Defaults and Hardening.

Tools

  • Payload embedding into documents: oxml_xxe, docem, XXElixir (XLSX), for SVG/DOCX/XLSX/PPTX/ODT upload testing (oxml_xxe, docem).
  • Automated exploitation: XXEinjector (OOB via FTP/HTTP/Gopher, directory listing, Java JAR schema), XXExploiter, XXE-OOB-Exfiltrator (XXEinjector, XXExploiter).
  • OOB infrastructure: Burp Collaborator, Interactsh, xxe-ftp-server (records exfiltrated data as an FTP password; reveals Java version/internal IPs).
  • Local-DTD discovery: GoSecure dtd-finder (Advanced XXE Exploitation).
  • Detection: Nuclei templates, Burp HackBar payloads, and OOB listeners on a DAST pipeline (Burp HackBar).

Sub-pages

Sources