
Hey guys, Rocky here! 📄🔓
Welcome to Day 11 of the Daily Web Hacking series! Today, we’re diving into Part 11: XXE Attacks—the art of exploiting XML parsers to steal secrets, crash systems, and even own servers. Imagine tricking an app into spilling its deepest secrets by feeding it a malicious “document.” Let’s break it down!
—
What is XXE?
XML External Entity (XXE) Injection is a vulnerability that abuses XML parsers to read files, execute remote requests, or launch denial-of-service (DoS) attacks. By injecting malicious XML entities, attackers can:
- Steal sensitive files (
/etc/passwd
, .env
, database backups).
- Perform SSRF (Server-Side Request Forgery) to attack internal systems.
- Crash servers via Billion Laughs attacks.
Why it’s dangerous:
- #4 in the OWASP Top 10 (2021).
- Found in 34% of web apps (PortSwigger, 2023).
- Often leads to full server compromise.
—
XML Basics: The Language of Data
XML (eXtensible Markup Language) structures data using tags. For example:
<user>
<name>Rocky</name>
<email>rocky@hacklivly.com</email>
</user>
Entities are XML’s “variables.” They can reference data inside or outside the document:
<!ENTITY internal "Hello">
<!ENTITY external SYSTEM "file:///etc/passwd">
Key Insight: If a parser resolves external entities, attackers can exploit it.
—
How XXE Works
Attacker Submits Malicious XML:
<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<user>&xxe;</user>
Server Parses the XML:
Server Returns the File:
<user>root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...</user>
Boom—sensitive data leaked!
—
Types of XXE Attacks
1. File Disclosure
2. SSRF (Server-Side Request Forgery)
3. Blind XXE
4. Billion Laughs (DoS)
—
Real-World XXE Disasters
- Facebook (2013): XXE in SAML authentication leaked internal files.
- WhatsApp (2019): XXE in media processing exposed user data.
- Billion Laughs in the Wild: Took down major e-commerce sites.
Lesson: XXE is a silent killer.
—
Step-by-Step Exploitation
Goal: Steal /etc/passwd
from a vulnerable XML parser.
1. Find an XML Input
- Look for file uploads, SOAP APIs, or document parsers (e.g., PDF, DOCX).
2. Test for XXE
3. Extract Data
- If the response includes
/etc/passwd
, you’ve struck gold.
4. Escalate to SSRF
—
Advanced XXE Techniques
1. PHP Wrapper Exfiltration
2. Error-Based Exfiltration
3. SVG XXE
—
Tools for XXE Exploitation
1. Burp Suite
- Repeater: Test payloads manually.
- Collaborator: Detect blind XXE via DNS/HTTP callbacks.
2. XXEinjector
3. OWASP ZAP
- Automated scanning for XXE vulnerabilities.
—
Defending Against XXE
For Developers
Disable DTDs:
Java:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
.NET:
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Prohibit;
Use Safe Parsers:
Input Validation:
For Admins
Web Application Firewall (WAF):
- Block requests with
<!DOCTYPE
or SYSTEM
.
File Upload Restrictions:
Log Monitoring:
—
Practice Legally: Labs & Challenges
- PortSwigger Labs:
- Hack The Box:
- Machines like Silo (Oracle XXE) and Bart (Blind XXE).
- OWASP Juice Shop:
- Practice XXE in the File Complaint challenge.
—
Ethical Hacking & Reporting
Never exploit XXE without permission. If you find a flaw:
- Document: Record steps to reproduce.
- Report: Use the site’s security contact or bug bounty program.
- Disclose: Wait for a fix before sharing publicly.
—
What’s Next? Part 12: Server-Side Template Injection (SSTI)
Tomorrow, we’ll explore SSTI—injecting malicious code into server-side templates (Jinja2, Twig, etc.). Sneak peek:
{{ 7 * 7 }} <!-- Outputs 49 if vulnerable -->
—
Final Thoughts
XXE is a silent predator lurking in XML parsers. By disabling DTDs, validating inputs, and adopting secure coding practices, you can shut this attack vector down. Remember: Trust no input, and always parse with paranoia.
Rocky Signing Off! ✌️
—
P.S. If you’re loving this series, share it with your hacking crew! Let’s turn script kiddies into security ninjas.
Discussion Question: What’s the wildest file you’ve accessed via XXE? I once leaked a Bitcoin wallet.dat from a misconfigured server. 😅 Spill your stories below! 👇