Executive brief
psd-tools is a Python library for reading and manipulating Adobe Photoshop PSD files. The composite() and numpy() functions allocate output image buffers based on dimensions declared in the PSD file header without validating those values. An attacker can craft a tiny malicious PSD file (under 100 bytes) that declares extremely large image dimensions, causing the library to allocate gigabytes of memory. Since the library returns successfully with only a warning rather than raising an error, applications processing untrusted PSD files face denial-of-service risk via memory exhaustion and system crashes.
Technical details
The vulnerability is an uncontrolled memory allocation issue in psd-tools' composite() and numpy() methods. The root cause is that these functions size output buffers based on width, height, channels, and bit-depth values read directly from the PSD file header, without validating them against the actual file length or enforcing reasonable limits. The attack vector is network/adjacent (processing untrusted PSD files), requires no authentication, and no user interaction beyond calling the affected methods. An attacker can amplify a 49-byte input into 3–32 GB of committed memory depending on which method is called and which dimension parameters are crafted. The critical issue is that composite() returns a black image with only a warning, providing no exception for callers to catch and prevent the OOM. The suggested fix involves pre-allocation validation against file length and configurable pixel/byte budgets, with error handling to raise exceptions rather than silently committing memory.
Affected products
- psd-tools psd-tools 1.17.2 and likely earlier versions
Timeline
- 2026-09-22: disclosed: GHSA-8q6g-vjhf-jp8m published