Resource Exhaustion via File Processing
What you'll learn: How attackers use specially crafted files to consume excessive server resources and cause denial-of-service conditions.
The Core Problem
Resource exhaustion attacks exploit file processing systems by uploading files that appear small but expand or require massive computational resources when processed. The goal is to overwhelm the server's CPU, memory, or disk space, making the application unavailable to legitimate users.
Common Attack Techniques
Zip Bombs (Decompression Bombs)
A zip bomb is a tiny compressed archive that expands to enormous size when decompressed. For example, a 42-kilobyte ZIP file might contain nested archives that expand to petabytes of data. When your server tries to extract this file, it consumes all available disk space and memory.
Think of it like a magic bag that looks pocket-sized but contains an entire ocean inside—your server drowns trying to process it.
Billion Laughs Attack (XML Bombs)
This attack uses XML entity expansion to multiply data exponentially. A small XML file defines entities that reference each other recursively, causing the parser to expand the document billions of times. What starts as a few kilobytes becomes gigabytes in memory.
Pixel Flooding
An attacker uploads an image file claiming dimensions like 1000000x1000000 pixels. When your image processing library tries to allocate memory for this, it requests terabytes of RAM, crashing the server.
Algorithmic Complexity Attacks
Some file formats trigger worst-case processing algorithms. For example, carefully crafted regular expressions in document processing or pathological JPEG files that force excessive recompression attempts.
Real-World Impact
These attacks are dangerous because they require minimal bandwidth to execute but cause maximum damage. A single malicious file can take down an entire service.
Key Takeaway: Always implement resource limits (file size caps, decompression depth limits, processing timeouts) and validate file dimensions before processing to prevent resource exhaustion attacks from bringing down your application.