
Dompdf: Denial of Service (DoS) via Resource Exhaustion using Oversized Image Bitmaps
This repository and its content are provided for educational and research purposes only. The author is not responsible for any misuse, damage, or illegal activities conducted with the information provided here. Always obtain authorization before testing target environments.
Dompdf v3.1.5 is vulnerable to a Denial of Service (DoS) attack via resource exhaustion. An attacker can crash the PHP process by providing a specially crafted HTML document containing a single image with massive dimensions (e.g., 30,000x30,000 pixels).
While Dompdf implements internal checks to validate image dimensions, these can be bypassed by using a high-entropy image (such as random noise) encoded in Base64 and wrapped in specific CSS containers.
Standard solid-color images can often be optimized by compression algorithms or rendering engines. However, a high-entropy noise image forces the PHP engine to process each of the 900 million pixels individually. When render() is called, the engine attempts to handle the uncompressed bitmap in memory and calculate the layout for every high-variance pixel data point. This leads to:
The vulnerability exists because the dimension validation happens early, but the resource allocation for calculating the object's bounding box and internal buffers during the rendering phase does not strictly limit the cumulative CPU time or memory usage for a single object that has passed the initial check.
https://github.com/user-attachments/assets/d1f5a07b-a7c5-4b5e-84b5-1e47e73522d9
composer require dompdf/dompdf:3.1.5
exploit.py):monitor.py):render.php. This script acts as the vulnerable entry point, mimicking a standard implementation of the Dompdf library:php -d memory_limit=2G render.php < payload.html
The following logs demonstrate the successful exploitation of the resource exhaustion vulnerability. Despite a generous 2GB memory limit provided to the PHP process, a single high-entropy image causes a fatal crash.
python3 exploit.py
[*] Generating 30000x30000 High-Entropy Noise Bomb...
[+] High-entropy payload saved to: payload.html
php -d memory_limit=2G render.php < payload.html
Output
[*] Starting Dompdf rendering process...
PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 1200355712 bytes) in /home/far00t/dompdf_exploit/vendor/dompdf/dompdf/src/Dompdf.php on line 490
While executing the render.php process, the monitor.py script captured the following telemetry, showing the impact on system resources:
python3 monitor.py
[*] Searching for PHP processes... (Press Ctrl+C to stop)
[MONITOR] PID: 210767 | RAM: 953.17 MB | CPU: 99.7%
An unauthenticated remote attacker can cause a complete Denial of Service on the web server by submitting a crafted HTML string. This affects any application that allows users to provide HTML content or URLs that are subsequently converted to PDF using Dompdf.