November 13, 2026
Exploiting XXE using external entities to retrieve files: A Step-by-Step Walkthrough
Behind an innocent “Check Stock” button lay an overly trusting XML parser — and a wide-open door to the server’s most sensitive files.
By Spoorthi
1 min read
Behind an innocent "Check Stock" button lay an overly trusting XML parser — and a wide-open door to the server's most sensitive files.
XML External Entity (XXE) injection happens when an application parses XML input without disabling dangerous external entity references. When left unchecked, an attacker can define custom entities that point directly to local files on the server and force the application to read them back.
In this walkthrough, we will solve the Exploiting XXE using external entities to retrieve files lab from PortSwigger's Web Security Academy.
The Objective
Our goal is to exploit an XXE vulnerability in a web store's stock-checking feature to read and display the contents of the /etc/passwd file from the underlying server.
Step 1: Intercept the Check Stock request
First, launch the lab and keep Burp Suite open.
- Browse to any product page on the target web store.
- Scroll down and click the Check stock button.
- Switch to your proxy's HTTP history tab and locate the
POST /product/stockrequest. - Right-click the request and send it to Repeater so we can modify and resend the payload easily.
Step 2: Analyze the XML Structure
Looking at the request body in Repeater, we see that the application sends product and store identifiers in standard XML format:
Step 3: Inject the Payload and Retrieve the File
To read /etc/passwd, we need to define a Document Type Declaration (DOCTYPE) containing an external entity pointing to file:///etc/passwd, and then reference that entity inside the <productId> tag.
Modify the XML payload in Repeater so it looks like this: