XML injection (XXE - XML External Entity)
Understanding XML Injection
What is XXE Injection?
Vulnerable Code Example
// PHP vulnerable XML processing
$xml_data = $_POST['xml'];
// Vulnerable: libxml with external entities enabled
$dom = new DOMDocument();
$dom->loadXML($xml_data);
// External entities processed by default
$xpath = new DOMXPath($dom);
$result = $xpath->query('//user/name');
echo "User: " . $result->item(0)->nodeValue;Normal XML Request:
<?xml version="1.0"?>
<user>
<name>John</name>
<email>john@example.com</email>
</user>How XXE Injection Works
XML Entity Types
Impact and Consequences
XML Parser Behavior and Detection
Common XML Parsers
Detection Methodology
Basic XXE Exploitation Techniques
Local File Disclosure
Direct File Reading
Windows File System Access
Environment-Specific Paths
Server-Side Request Forgery (SSRF)
Internal Network Scanning
Cloud Metadata Access
Protocol Exploitation
Advanced XXE Exploitation
Blind XXE Exploitation
Out-of-Band Data Exfiltration
Error-Based Blind XXE
Time-Based Blind XXE
XXE with Parameter Entities
Complex Parameter Entity Attacks
UTF-16 Encoding Bypass
Protocol Handler Exploitation
PHP Wrapper Exploitation
Data URI Exploitation
Java-Specific Protocol Handlers
Denial of Service Attacks
Billion Laughs Attack
Exponential Entity Expansion
Quadratic Blowup Attack
External Resource Exhaustion
Slow Loris Attack
Recursive Entity Loading
XXE in Different Application Contexts
Web Services and APIs
SOAP Web Services
REST API with XML Content
File Upload and Processing
Document Upload XXE
Configuration File Processing
Content Management Systems
WordPress XML-RPC
Drupal XML Processing
XXE in Mobile Applications
Android Application XXE
XML Parsing in Android
iOS Application XXE
Advanced Exploitation Scenarios
Multi-Stage XXE Attacks
XXE to RCE Chain
XXE to SSRF to Internal Network Compromise
Last updated
Was this helpful?