Portswigger Labs

Lab 1: XXE for Arbitrary File Read

This lab is solved by reading /etc/passwd, and it uses a 'Check stock' function that parses XML input:

This is an apprentice lab, so this can be solved using a basic payload.

Here's the script:

Lab 2: XXE for SSRF

To solve lab, access http://169.254.169.254/ and read some sensitive information from there.

When I used the same payload as above (with the file:///etc/passwd replaced with the HTTP URL), I get this:

Appending /latest results in a different response:

Setting the URL to http://169.254.169.254/latest/meta-data/iam/security-credentials/admin solves the lab.

Lab 3: Out of Band Interaction

This lab requires us send a HTTP request to a Burp Collaborator link. This is a blind XXE example.

Lab 4: Out of Band via XML parameter entities

This lab blocks regular external entities. Trying to use ENTITY results in a block:

Regular external entities are custom XML entities whose defined values are loaded from outside of the DTD they are declared in. This means that for this lab, I cannot define my own entities.

As such, I can use the stockCheck entity, which is given to me. Next, I need to figure out how NOT to use custom regular external entities. PayloadAllTheThings uses this:

Using a % changes it to a parameter entity, which can only be referenced elsewhere within the DTD (hence using stockCheck).

Thus, the payload is as such:

Lab 5: Blind XXE using malicious external DTD

To solve this lab, read /etc/hostname. This lab gives me an Exploit Server, as well as a Submit Feedback function.

The submit feedback function wasn't particularly interesting.

I was unable to read files using the method used in Lab 4. However, I was able to make the lab send a request to Burp Collaborator. Since I was given an Exploit Server, I can try to store a malicious DTD on it.

I want to extract the data from /etc/hostname, and then send that to Collaborator. I stored this file on the exploit server:

&#x25 represents a % in Unicode, and it is used to prevent syntax errors. After storing this on the exploit server, I used this payload to make the application retrieve it and process it.

This would trigger a lookup to Collaborator:

Submitting that value solves the lab.

Lab 6: Error based blind XXE

To solve this lab, use an external DTD to trigger an error message that displays /etc/passwd.

The error can be triggered by trying to read a file that does not exist.

This would append the contents of the file behind the error message.

Lab 7: Exploiting XInclude

This time, the page no longer uses client-side XML to process it:

As such, XInclude has to be used to exploit this. XInclude is part of the XML specification that allows XML docs to be built from sub-documents. All I have to do is reference the XInclude namespace.

Set the above as the productId parameter to solve the lab.

Lab 8: XXE via Image File Upload

This lab uses the Apache Batik library to process image files. Read /etc/hostname to solve lab. The hint is the the SVG image format uses XML.

Here's the payload from PayloadAllTheThings:

Using the above payload, save it as a .svg file, and then upload it.

Upon viewing the image, I can see the result:

As usual, here's the script for uploading the image and solving the lab:

Lab 9: Repurposing Local DTD

This lab requires us to use the /usr/share/yelp/dtd/docbookx.dtd to exploit it, and within that particular DTD is an entity called ISOamso.

To solve the lab, firstly, we have to reference the local DTD, and I used a parameter entity:

Next, I have to redefine the ISOamso entity, and I took the payload from PayloadAllTheThings:

So the final payload is:

Last updated