Executive brief
psd-tools is a Python library for reading and writing Adobe Photoshop PSD/PSB files. The compression module has multiple vulnerabilities including unguarded zlib decompression that can be exploited via crafted PSD files to exhaust memory (ZIP bomb), missing validation of image dimensions that can cause uncontrolled memory allocation, and use of assertions as runtime integrity checks which can be disabled in optimized Python deployments. An attacker can cause a denial-of-service crash by providing a malicious PSD file.
Technical details
The vulnerability consists of multiple security issues in the psd_tools.compression module: (1) Unguarded zlib.decompress() calls without max_length caps allow ZIP bomb attacks—a crafted PSD file with ZIP-compressed channel data can expand to gigabytes, exhausting process memory before any limit is enforced (CWE-409: Improper Resource Validation). (2) Missing upper-bound validation on image dimensions (width, height, depth) before memory allocation allows uncontrolled allocation attempts on malformed PSB files containing dimensions up to 300,000×300,000 pixels, resulting in hard crashes instead of recoverable errors (CWE-190: Integer Overflow). (3) Use of Python assert statements as runtime integrity checks which can be silently disabled when the interpreter runs with -O flags, allowing length mismatches to propagate silently (CWE-390: Detection Using an Incorrect Regular Expression). Additionally, minor type mismatches in Cython code and silent data degradation issues are noted. Patches are available in version 1.12.2, which adds max_length constraints to zlib.decompress() and explicit dimension validation with descriptive error messages.
Affected products
- psd-tools psd-tools < 1.12.2
Timeline
- 2026-02-26: disclosed
- 2026-02-25: patched: Patches available in version 1.12.2 and later