CrImage::DecompressionGuard
DecompressionGuard provides protection against decompression bombs (also known as zip bombs or compression bombs).
A decompression bomb is a maliciously crafted compressed file that expands to an enormous size when decompressed, potentially exhausting system memory and causing denial of service.
This module tracks compressed vs decompressed data ratios and enforces configurable limits to prevent such attacks.
Constants
Maximum total decompressed size (500MB by default) This is separate from InputValidation's pixel area limit
Default maximum expansion ratio (compressed:decompressed) A 1KB compressed file can expand to at most 1000KB (1MB)
Minimum compressed size to start checking ratio (1KB) Files smaller than this are exempt from ratio checks
Class methods
Create a new guard for a specific format
Wrap an IO to track compressed bytes read
Wrap an IO to track decompressed bytes written