CVE-2026-32274: psf Black arbitrary file write via unsanitized cache filename

CVE-2026-32274 · Severity: high · CVSS 7.5 · Published 2026-03-12

Black, a popular Python code formatter, contains a vulnerability that allows an attacker to write files to unauthorized locations on a computer's file system. By providing a specially crafted input to a specific configuration option, an attacker could potentially overwrite critical system or application files. This could lead to system instability or be used as a stepping stone for further attacks.

Technologies: black (PyPI), Red Hat OpenShift Lightspeed. Vendors: PyPI, Python, Red Hat.

Quick answers

Is CVE-2026-32274 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-32274 being exploited in the wild.
How severe is CVE-2026-32274?
High severity, with a CVSS score of 7.5, published 12 March 2026.
Which products and versions are affected?
black (PyPI) ECOSYSTEM:introduced=0,fixed=26.3.1, ECOSYSTEM:introduced=24.3.0,fixed=26.3.1.
Is there a fix for CVE-2026-32274?
Yes. black (PyPI): upgrade to 26.3.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-32274 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-32274?
Check whether you run black (PyPI), Python Black or Red Hat OpenShift Lightspeed at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • black (PyPI): upgrade to 26.3.1 or later
    pip install "black>=26.3.1"

Technical details

A path traversal vulnerability exists in Black's caching mechanism. The application constructs cache filenames using various formatting options, including the value provided to the `--python-cell-magics` command-line argument. Because this value is not sanitized before being incorporated into the file path, an attacker who can control this argument can perform a path traversal attack to write cache files to arbitrary locations on the filesystem. This is tracked as CWE-22. The issue is fixed in version 26.3.1 by implementing proper sanitization of the affected option.

Affected products

  • psf black >= 24.3.0, < 26.3.1

Identifiers

  • CVE-2026-32274
  • GHSA-3936-cmfr-pm3m
  • PYSEC-2026-2121

Timeline

  • 2026-03-12: disclosed
  • 2026-03-12: advisory
  • 2026-03-12: patched

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.