In-Band XXE
The file/URL content gets reflected directly into the application’s response. Easiest to confirm and exploit.
Blind / Out-of-Band XXE
No output comes back. Confirm and exfiltrate via a Document Type Definition (DTD) hosted on your own server and a callback you control instead.
How It Works
The core trick: declare an entity in aDOCTYPE, then reference it anywhere in the document body. The parser resolves the entity before handing the document to the application, so whatever you pointed it at gets included in as if it were always part of the XML.
SYSTEM identifier accepts other protocols/wrappers, each useful for a different goal.
php://filter matters more than it looks: a file containing raw binary data, null bytes, or characters that aren’t valid XML/UTF-8 will break the parser or truncate the output if read directly.Advanced: CDATA Wrapping
The content of the reflected file is sometimes still escaped or otherwise corrupted by the application after the XML parser has processed it. By embedding the result in aCDATA section, any subsequent processing is instructed to treat it as a raw literal block instead, which often preserves content that would otherwise be corrupted or truncated.
% prefix) instead, which are evaluated inside the DTD itself rather than the document body.
Error-Based XXE
When the application reflects parser errors but not actual content, deliberately triggering an error that includes the file’s content as part of the (invalid) entity reference leaks it through the error message instead.Out-of-Band (Blind) Exfiltration
When there’s no visible output and no useful error either, the last option is making the target server reach out to you directly, carrying the file’s content along in the request.1
Write the external DTD file
2
Serve the DTD file
3
Stand up a listener to catch the exfiltrated data
A second listener (different port) logs whatever comes back in the
content parameter.4
Submit the payload referencing your hosted DTD
Automated Exfiltration with XXEinjector
For repeated or multi-file extraction, automating the OOB chain above saves a lot of manual DTD-writing.XXEINJECT in place of the XML body.
SVG-Based XXE
SVG is XML under the hood, so any upload feature accepting SVG images is a potential XXE vector, worth testing alongside standard file-upload bypasses (see File Upload Attacks).<!DOCTYPE svg tag
Denial of Service: Billion Laughs
Each entity references the previous one ten times over, so by the tenth layer, a few dozen bytes of definitions expand into billions of repetitions in memory, exhausting the server before any content is even returned. Not useful for data extraction, but worth knowing as a DoS vector if availability testing is in scope.When DOCTYPE Is Blocked
XInclude as a DOCTYPE-free alternative
XInclude as a DOCTYPE-free alternative
Some applications block or strip
<!DOCTYPE from the input before parsing, but still parse the resulting XML with an engine that supports XInclude, which achieves a similar file-read result without ever declaring a DOCTYPE at all. Useful specifically when your input lands inside an existing XML document (so you can’t control the DOCTYPE) rather than being the entire document yourself.Common hardening targets worth checking first
Common hardening targets worth checking first
/etc/passwd, /etc/hosts, and /proc/self/environ are the standard confirmation targets, but once XXE is confirmed, also worth checking: ~/.ssh/id_rsa, application config files (.env, web.config, wp-config.php) for credentials.Quick Reference Tools
Hackviser: XXE
Reference used for this page.
HackTricks: XXE
Deeper dive into additional bypasses and content-based evasion.
convertjson.com
Quick JSON-to-XML conversion for testing XML on JSON-only endpoints.
XXEinjector
Automates blind/OOB XXE exfiltration from a captured request.
OXML_XXE
Injects XXE payloads into Office/OpenXML document formats (docx, xlsx).

