Skip to content

XXE injection techniques

XXE injection techniques span local file read, SSRF, blind and out-of-band exfiltration, and XML-backed formats like SVG, DOCX and SAML. Each technique page explains how it works, which parser configuration makes it possible, how to detect it, and the exact fix.

Billion Laughs XML bomb

The Billion Laughs XML bomb is a denial-of-service cousin of XXE: it defines nested internal entities that each reference the previous one ten times, so a few lines expand exponentially into gigabytes of text when the parser resolves them, exhausting memory or CPU — no external resources required.

Denial of serviceMemory exhaustionCPU exhaustion
blind XXE out-of-band exfiltration

Blind XXE out-of-band exfiltration is how you extract data when the parser resolves entities but never reflects them: you host an external DTD that reads a local file into a parameter entity and smuggles it into the query string of a request back to your server, so the file contents arrive in your access logs.

Blind file disclosureData exfiltration
classic XXE file disclosure

Classic XXE file disclosure is the textbook XML External Entity attack: you declare an external entity that points at a local file with the file:// scheme, reference it inside an element the application reflects in its response, and the vulnerable parser resolves the entity and returns the file contents.

Local file disclosureConfig/secret theftSource code read
error-based XXE exfiltration

Error-based XXE exfiltration leaks data when there is no out-of-band channel: you craft parameter entities so the target file's contents are placed inside an invalid SYSTEM path, and the parser's verbose error message quotes that path — file contents and all — straight back in the HTTP response.

Blind file disclosureData exfiltration

Local DTD reuse XXE lets you exfiltrate data when the server has no outbound network at all: instead of hosting your own external DTD, you reference a DTD file that already exists on the target (such as a GNOME or Linux docs DTD) and redefine one of its parameter entities to run the error-based chain entirely locally.

Blind file disclosure without outbound network
JSON to XML XXE content-type

The JSON to XML XXE content-type attack exploits APIs that advertise JSON but will also accept XML: by changing the Content-Type header to application/xml and resubmitting the body as XML, you can reach an underlying XML parser that the JSON interface hid, and trigger external entity injection against it.

Local file disclosureSSRFBlind exfiltration

SAML XXE targets single sign-on: a SAMLResponse is an XML document the service provider parses to authenticate users, so injecting a DOCTYPE with an external entity into that XML can make the SP's parser read local files or issue server-side requests while it processes the login.

Local file disclosureSSRFAuth-flow compromise
XXE to SSRF

XXE to SSRF turns an XML External Entity flaw into server-side request forgery: instead of a file:// URL, the external entity uses http:// so the vulnerable parser fetches an attacker-chosen internal address, reaching cloud metadata services, internal admin panels and other hosts the server can see but you cannot.

SSRFCloud metadata/credential theftInternal network access

DOCX XXE attacks target servers that parse uploaded Office documents: DOCX, XLSX and PPTX files are ZIP archives of XML parts, so injecting a DOCTYPE and external entity into one of those parts (such as word/document.xml) makes a vulnerable server-side XML parser read local files when it processes the upload.

Local file disclosureSSRFBlind exfiltration
SVG XXE upload

SVG XXE upload attacks exploit the fact that SVG is XML: an image upload that accepts SVG and parses or rasterises it server-side (thumbnailing, conversion, metadata extraction) will resolve an embedded external entity, turning a harmless-looking image into a local file-read primitive.

Local file disclosureSSRF
XInclude attack

An XInclude attack is the way to achieve XXE-style file reads when you only control part of an XML document and cannot add a DOCTYPE: you inject an `xi:include` element referencing a local file, and a parser with XInclude processing enabled substitutes the file's contents into the document.

Local file disclosureSSRF
XXE parameter entities

XXE parameter entities are a special entity type usable only inside the DTD, written with a percent sign (`%name;`). They are the engine behind blind and error-based XXE, and the fallback when an application strips or blocks ordinary general entities but still processes the DTD's internal subset.

Filter bypassBlind file disclosureExfiltration primitive
PHP XXE php://filter

PHP XXE php://filter attacks extend classic file reads on PHP targets: the php://filter wrapper base64-encodes a file before the entity returns it, so source code and files containing XML metacharacters survive, while the expect:// wrapper (when installed) can turn XXE into command execution.

Source code disclosureConfig/secret theftRCE (expect://)

Hardening your parsers

The fastest way to close every technique above is to disable DOCTYPE and external entities in your XML parser.

Browse the per-language hardening guides