Test files › Structured data › xxe-file-disclosure.xml
XXE external entity test XML
XML declaring an external entity that reads a local file. Targets /etc/hostname - deliberately innocuous rather than /etc/passwd.
↓ Download xxe-file-disclosure.xml| Filename | xxe-file-disclosure.xml |
| Format | XML |
| Size | 141 bytes (141 bytes) |
| MIME type | application/xml |
| SHA-256 | 3b24847c3f0f1c1e34b3d8b2bee9d2229da9613a35b7163bb4842ffcaf4aae83 |
What this file catchesParsers with external entity resolution enabled by default (older libxml2, Java DocumentBuilder, .NET XmlTextReader). If the response echoes your hostname back, you have a file-disclosure hole.
Handle it in code
Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.
Python
Python's standard parser (expat 2.4.1 or later) refuses entity-expansion bombs and does not fetch external entities, so this file fails to parse instead of attacking you. Parsers in other languages differ: make sure DTDs and external entities are disabled in yours. For untrusted XML in Python, the defusedxml package forbids entity declarations outright.
import xml.etree.ElementTree as ET
try:
ET.parse("xxe-file-disclosure.xml")
print("parsed")
except ET.ParseError as e:
print("refused:", e)Run against this file, it prints: refused: undefined entity &xxe;: line 6, column 8
Related guides and tools
Download & verify
curl -fsSL -o "xxe-file-disclosure.xml" "https://files.hexaqa.com/xml/xxe-file-disclosure.xml"
curl -fsSL "https://files.hexaqa.com/xml/xxe-file-disclosure.xml" | sha256sum
# expect: 3b24847c3f0f1c1e34b3d8b2bee9d2229da9613a35b7163bb4842ffcaf4aae83