Course contentsShow
← Security
Lesson 620 of 3,05213. Web Security - Injection AttacksFree lesson

XXE Attack Types: File Disclosure

Learn how attackers exploit XXE to read local files, including system files and application source code.

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:

  1. Reads the /etc/passwd file from the server
  2. Replaces &xxe; with the file's contents
  3. 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.