XXE Attack Types: File Disclosure
What You'll Learn
You'll learn how attackers exploit XML External Entity (XXE) vulnerabilities to read sensitive local files from a server's file system.
The Core Exploit
File disclosure is the most common XXE attack. Once an attacker identifies that an XML parser processes external entities (from XXE fundamentals), they can instruct it to read arbitrary files from the server's local filesystem—essentially turning the parser into a file-reading tool.
Think of it like this: Imagine a librarian (the XML parser) who follows instructions blindly. If you submit a request card that says "fetch the file at /etc/passwd," the librarian retrieves it and hands it back to you—even though that file was never meant to leave the library.
How It Works
The attacker crafts malicious XML that defines an external entity pointing to a local file path:
<!DOCTYPE data [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<userInfo>
<name>&xxe;</name>
</userInfo>
When the vulnerable parser processes this XML, it:
- Reads the
/etc/passwdfile from the server - Replaces
&xxe;with the file's contents - Returns the data in the application's response
Common Targets
Attackers typically target:
- System files:
/etc/passwd,/etc/hosts, Windows registry files - Application source code: Configuration files, API keys, database credentials
- Sensitive logs: Access logs containing user data
The attacker can read any file the application server has permission to access.
Key Takeaway: XXE file disclosure transforms an XML parser into a file-reading backdoor, letting attackers extract system files, application secrets, and source code directly through XML input.