XXE / XSLT
XML External Entity
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE email [
<!ENTITY company SYSTEM "http://localhost/company.txt">
<!ENTITY signature SYSTEM "file:///var/www/html/signature.txt">
]>Detection
In your proxy interceptor, add a match&replace rule to change content type "application/json" to "text/xml"
All you have to do now is look for XML parsing errors



Note: Some web applications may default to a JSON format in HTTP request, but may still accept other formats, including XML. So, even if a web app sends requests in a JSON format, we can try changing the Content-Type header to application/xml, and then convert the JSON data to XML with an online tool. If the web application does accept the request with XML data, then we may also test it against XXE vulnerabilities, which may reveal an unanticipated XXE vulnerability.
Change content type "application/json" to "application/xml"

Burp Extension - Content Type Converter
Read File

Read the content of sensitive files, like configuration files that may contain passwords or other sensitive files like an id_rsa SSH key of a specific user
Read the source code of the web application
If a file contains some of XML's special characters (e.g. </>/&), it would break the external entity reference and not be used for the reference. Furthermore, we cannot read any binary data, as it would also not conform to the XML format. Solution for PHP app: Base64

PHP Filters:
File Inclusion LFI / RFIFor Java app, see Bad characters - wrapper
Using SVG Image
Remote Code Execution with XXE
PHP://expect filter
Other XXE Attacks
Port scan, SSRF
DoS:
This attack no longer works with modern web servers (e.g., Apache), as they protect against entity self-reference
Advanced Exfiltration with CDATA
Error Based XXE

DTD file - xxe.dtd
payload

Out-of-band Data Exfiltration
Dtd file:
Payload:
Automation - XXEInjector
See Tools
Copy the HTTP request from Burp and write it to a file. Not include the full XML data, only the first line, and write XXEINJECT after it as a position locator for the tool:
All exfiltrated files get stored in the Logs folder under the tool

Tools
After identifying a Blind XXE for example in Burpsuite it is pretty straight forward with this tool. Simply save the request into a file (req.txt for example) and insert XXEINJECT at the location of the identified injectible parameter. https://blog.kennyjansson.com/2018/03/31/automating-blind-xxe-injection/

More payloads
Basic XXE
Lister des répertoires
file:/// : liste la racine file:///home/ : liste /home
XXE to SSRF
Blind XXE
Tool: XXEInjector
Nuclei Template
https://github.com/coffinxp/priv8-Nuclei/blob/main/blind-xxe.yaml
Out of Band
OOB Detection

OOB using SVG Image
DTD Exfiltration

FTP


also: https://github.com/cyberaz0r/XXE-OOB-Exfiltrator
Not able to exfiltrate /etc/passwd over http, or ftp on java/tomcat:

Bad characters - Wrapper DTD - CDATA


Repurposing Loacl DTD
Find a local DTD to repurpose
RCE in PHP
Try to use the expect package

Resources
XSLT Recon
Determine the Vendor and Version
Fingerprinting
File Read

XSS
RCE

SSRF
Payloads
Interesting Books
Interesting BooksThe Web Application Hacker’s Handbook The go-to manual for web app pentesters. Covers XSS, SQLi, logic flaws, and more
Bug Bounty Bootcamp: The Guide to Finding and Reporting Web Vulnerabilities Learn how to perform reconnaissance on a target, how to identify vulnerabilities, and how to exploit them
Real-World Bug Hunting: A Field Guide to Web Hacking Learn about the most common types of bugs like cross-site scripting, insecure direct object references, and server-side request forgery.
Support this Gitbook
I hope it helps you as much as it has helped me. If you can support me in any way, I would deeply appreciate it.
Resources
Last updated

