CVE-2026-59991: Psd tools Psd-tools Composite/numpy Has Uncontrolled Memory Vulnerability

HIGH
Advisory Identifier: GHSA-8q6g-vjhf-jp8m
CVSS 7.5
CWE-789
Published
Advisory Summary

CVE-2026-59991 is a HIGH (CVSS 7.5) psd-tools composite/numpy has uncontrolled memory vulnerability (CWE-789: Memory Allocation with Excessive Size Value) affecting Psd tools libraries in the PyPI ecosystem. The issue involves psd-tools composite/numpy has uncontrolled memory allocation via crafted psd geometry. Remediation is available by upgrading affected packages to version 1.17.4.

CVE-2026-59991 at a Glance

CVE Identifier CVE-2026-59991
GHSA Identifier GHSA-8q6g-vjhf-jp8m
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-789: Memory Allocation with Excessive Size Value
Affected Product Psd tools
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-59991

To remediate this vulnerability, upgrade all affected Psd tools dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

psd-tools fixed: 1.17.4
pip install psd-tools>=1.17.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show psd-tools

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-59991, inspect your installed packages using pip:

pip show psd-tools

Analyze the terminal output to locate any version of Psd tools in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.17.4), your application is affected.

Note: The pip show psd-tools command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-789: Memory Allocation with Excessive Size Value, where the product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated. In Psd tools, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary `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. ### Impact On 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. ### Steps to reproduce ```python # pip install psd-tools==1.17.2 from psd_tools import PSDImage psd = PSDImage.open("psd-psdtools-grammar-d23.psd") psd.composite() # commits ~3 GB from a 49-byte file and returns (warning only) ``` PoC (49 bytes), reconstruct with: ```sh base64 -d > psd-psdtools-grammar-d23.psd <<'EOF' OEJQUwABAAAAAAAAAAYAACg4AAAXTAAIAAMAAAAAAAAAAAAAAAAAAUNIUIFU+yQtDw== EOF ``` Verify: ``` 7d8ebf03a54393cb0359ecf4b676d1b08c9a8c6afdd06671ef406d6893cce826 psd-psdtools-grammar-d23.psd ``` ### Root cause The 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. ### Suggested fix Validate 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.

CVE-2026-59991 Affected Psd tools Versions

1 component(s)
Fixed Versions:
1.17.4
Product / Package Ecosystem Affected Versions Fixed Version
psd-tools
PyPI
< 1.17.4
1.17.4

References

Frequently Asked Questions

What is CVE-2026-59991?
CVE-2026-59991 is a security vulnerability in Psd tools involving psd-tools composite/numpy has uncontrolled memory allocation via crafted PSD geometry under CWE-789: Memory Allocation with Excessive Size Value.
Which Psd tools versions are affected?
Affected versions include releases prior to 1.17.4 across affected packages: psd-tools.
What version fixes CVE-2026-59991?
Upgrading to 1.17.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is psd-tools affected?
Yes, psd-tools is affected in releases prior to 1.17.4. Upgrade your dependency to 1.17.4 or later.
What is the CVSS score of CVE-2026-59991?
CVE-2026-59991 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-59991?
CVE-2026-59991 is classified under CWE-789: Memory Allocation with Excessive Size Value (The product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated.).
How can I check PyPI dependencies for CVE-2026-59991?
Run the dependency tree command: 'pip show psd-tools'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8q6g-vjhf-jp8m",
  "modified" : "2026-09-22T19:45:51Z",
  "published" : "2026-09-22T19:45:51Z",
  "aliases" : [ "CVE-2026-59991" ],
  "summary" : "psd-tools composite/numpy has uncontrolled memory allocation via crafted PSD geometry",
  "details" : "### 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "psd-tools"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.17.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/psd-tools/psd-tools/security/advisories/GHSA-8q6g-vjhf-jp8m"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/psd-tools/psd-tools/commit/a3d9a53ad51e667b5772a4f636ca6f2e16f4b271"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/psd-tools/psd-tools"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/psd-tools/psd-tools/releases/tag/v1.17.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-789" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-22T19:45:51Z",
    "nvd_published_at" : null
  }
}