CVE-2021-3902
📋 TL;DR
This XXE vulnerability in dompdf's SVG parser allows attackers to perform Server-Side Request Forgery (SSRF), access internal files, and execute PHAR deserialization attacks. It affects all versions of dompdf before 2.0.0 and can be exploited even when remote resource loading is disabled. Any application using vulnerable dompdf versions to process SVG files is at risk.
💻 Affected Systems
- dompdf/dompdf
📦 What is this software?
Dompdf by Dompdf Project
⚠️ Risk & Real-World Impact
Worst Case
Full server compromise through PHAR deserialization leading to remote code execution, data exfiltration, and lateral movement within the network.
Likely Case
SSRF attacks accessing internal services, reading sensitive files from the server filesystem, and potential denial of service.
If Mitigated
Limited impact if SVG processing is disabled or input validation blocks malicious SVG files.
🎯 Exploit Status
Exploitation requires SVG file upload or injection. Public proof-of-concept code exists in security advisories.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 2.0.0
Vendor Advisory: https://github.com/dompdf/dompdf/security/advisories/GHSA-3cw5-7cxw-v5qg
Restart Required: No
Instructions:
1. Update dompdf to version 2.0.0 or later using composer: composer require dompdf/dompdf:^2.0.0
2. Test SVG processing functionality after update
3. No server restart required for PHP applications
🔧 Temporary Workarounds
Disable SVG processing
allTemporarily disable SVG file processing in dompdf configuration
Set $dompdf->set_option('enable_svg', false); in your PHP code
Input validation for SVG files
allImplement strict validation of SVG file content before processing
Use XML validation to block external entity declarations in SVG files
🧯 If You Can't Patch
- Implement WAF rules to block SVG files containing XXE payloads
- Isolate dompdf processing to a restricted network segment with no internal access
🔍 How to Verify
Check if Vulnerable:
Check composer.json or vendor/dompdf/dompdf/VERSION file for version number. Versions below 2.0.0 are vulnerable.
Check Version:
php -r "require 'vendor/autoload.php'; echo \Dompdf\Dompdf::VERSION;"
Verify Fix Applied:
Verify dompdf version is 2.0.0 or higher. Test SVG processing with known safe files.
📡 Detection & Monitoring
Log Indicators:
- Unusual SVG file uploads
- Outbound HTTP requests from dompdf to internal IPs
- PHP errors related to XML parsing
Network Indicators:
- HTTP requests from application server to internal services on unusual ports
- File read attempts via file:// protocol
SIEM Query:
source="web_server" AND (uri_path="*.svg" OR user_agent CONTAINS "dompdf") AND status_code=200