{"id":"CVE-2026-59991","aliases":["CVE-2026-59991","GHSA-8q6g-vjhf-jp8m","PYSEC-2026-4139"],"related":[],"kind":"vulnerability","state":"published","title":"psd-tools: Uncontrolled memory allocation in psd-tools composite/numpy via crafted PSD geometry","summary":"psd-tools is a Python package for working with Adobe Photoshop PSD files. Prior to 1.17.4, PSDImage.composite() and PSDImage.numpy() allocated output buffers from attacker-controlled PSD header geometry, including width, height, channels, depth, and per-layer rectangles, before validating those values against the available file data. A tiny crafted PSD could therefore cause multi-gigabyte memory allocation, and PSDImage.composite() could return a black image with only a warning instead of raising an exception. Services that composite untrusted PSD files could be terminated by out-of-memory handling. This issue is fixed in version 1.17.4.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"psd-tools is a Python package for working with Adobe Photoshop PSD files. Prior to 1.17.4, PSDImage.composite() and PSDImage.numpy() allocated output buffers from attacker-controlled PSD header geometry, including width, height, channels, depth, and per-layer rectangles, before validating those values against the available file data. A tiny crafted PSD could therefore cause multi-gigabyte memory allocation, and PSDImage.composite() could return a black image with only a warning instead of raising an exception. Services that composite untrusted PSD files could be terminated by out-of-memory handling. This issue is fixed in version 1.17.4.","source":"cvelist"},{"lang":"en","text":"### Summary\n`PSDImage.composite()` (and `.numpy()`) allocate the output image buffer from the PSD's header geometry (width × height × channels × depth, and per-layer rectangles) before validating those values against the actual file contents. A tiny crafted PSD declaring huge dimensions causes a multi-gigabyte allocation. Critically, `composite()` then returns a (black) image with only a warning, no exception is raised, so a caller cannot detect or guard against it.\n\n### Impact\nOn psd-tools 1.17.2 (latest), default usage, a 49-byte PSD makes `composite()` commit ~3 GB and return successfully (warning only); `.numpy()` reaches ~7.5 GB, and the per-layer rectangle is a second lever (up to ~32 GB), all from an input under 100 bytes (input-to-commit amplification over 1000×). Because the buffer is committed before validation and no exception is thrown, any service that composites untrusted PSDs is exposed to denial of service: on a host with less RAM than the attacker-declared geometry the allocation is an unrecoverable OOM-kill. \n\n### Steps to reproduce\n```python\n# pip install psd-tools==1.17.2\nfrom psd_tools import PSDImage\npsd = PSDImage.open(\"psd-psdtools-grammar-d23.psd\")\npsd.composite()   # commits ~3 GB from a 49-byte file and returns (warning only)\n```\n\nPoC (49 bytes), reconstruct with:\n```sh\nbase64 -d > psd-psdtools-grammar-d23.psd <<'EOF'\nOEJQUwABAAAAAAAAAAYAACg4AAAXTAAIAAMAAAAAAAAAAAAAAAAAAUNIUIFU+yQtDw==\nEOF\n```\nVerify:\n```\n7d8ebf03a54393cb0359ecf4b676d1b08c9a8c6afdd06671ef406d6893cce826  psd-psdtools-grammar-d23.psd\n```\n\n### Root cause\nThe composite/numpy buffer is sized from the declared image (and per-layer) dimensions and channel/depth without checking them against the available data length or a sane maximum.\n\n### Suggested fix\nValidate the declared dimensions, channel count, and per-layer rectangles against the actual file length (and a configurable maximum pixel/byte budget) before allocating; raise an error on overflow instead of committing the buffer and returning a black image.","format":"markdown","source":"ghsa"}],"published":"2026-09-22T19:11:38.661Z","modified":"2026-10-01T17:56:13.306Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-789"],"affected":[{"ranges":[{"version":"< 1.17.4","status":"affected"}],"vendor":"psd-tools","product":"psd-tools","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.17.4"}],"ecosystem":"PyPI","package":"psd-tools","purl":"pkg:pypi/psd-tools","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.17.4"}],"ecosystem":"PyPI","package":"psd-tools","purl":"pkg:pypi/psd-tools","source":"pysec"}],"references":[{"url":"https://github.com/psd-tools/psd-tools/security/advisories/GHSA-8q6g-vjhf-jp8m","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/psd-tools/psd-tools/commit/a3d9a53ad51e667b5772a4f636ca6f2e16f4b271","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/psd-tools/psd-tools/releases/tag/v1.17.4","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/psd-tools/psd-tools","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/psd-tools","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-8q6g-vjhf-jp8m","tags":["advisory"],"sources":["pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-59991","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-09-22T19:36:58.263Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-59991","url":"https://www.cve.org/CVERecord?id=CVE-2026-59991","licence":"CVE Terms of Use","modified":"2026-09-22T19:37:39.755Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-8q6g-vjhf-jp8m","url":"https://github.com/advisories/GHSA-8q6g-vjhf-jp8m","licence":"CC-BY-4.0","modified":"2026-10-01T17:56:13.306Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-59991","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-59991","licence":"Public domain","modified":"2026-09-23T18:12:04.247Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-4139","url":"https://osv.dev/vulnerability/PYSEC-2026-4139","licence":"CC-BY-4.0","modified":"2026-10-01T17:45:16.013Z"}],"updatedAt":"2026-11-25T22:59:40.535Z","epss":{"score":0.00609,"percentile":0.43385,"date":"2026-11-30T12:00:22.000Z"}}