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

Source: https://junglewise.ai/threats/cve-2026-32274-psf-black-arbitrary-file-write-via-unsanitized-cache-filename  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-03-12. Updated: 2026-08-03  
License: CC BY 4.0 with a link back

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)](https://junglewise.ai/threats/technologies/pypi-black), [Red Hat OpenShift Lightspeed](https://junglewise.ai/threats/technologies/openshift-lightspeed). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi), [Python](https://junglewise.ai/threats/vendors/python), [Red Hat](https://junglewise.ai/threats/vendors/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

  ```sh
  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

- [https://api.github.com/users/fg0x0](https://api.github.com/users/fg0x0)
- [https://github.com/fg0x0](https://github.com/fg0x0)
- [https://api.github.com/users/fg0x0/gists%7B/gist_id%7D](https://api.github.com/users/fg0x0/gists%7B/gist_id%7D)
- [https://api.github.com/users/fg0x0/repos](https://api.github.com/users/fg0x0/repos)
- [https://avatars.githubusercontent.com/u/35772301?v=4](https://avatars.githubusercontent.com/u/35772301?v=4)
- [https://api.github.com/users/fg0x0/events%7B/privacy%7D](https://api.github.com/users/fg0x0/events%7B/privacy%7D)

## Related threats

- [Black GitHub Action code injection via unvalidated required-version](https://junglewise.ai/threats/cve-2026-114134-black-github-action-installs-unvalidated-required-version-from)
- [Kludex python-multipart denial of service in multipart header parsing](https://junglewise.ai/threats/cve-2026-42561-kludex-python-multipart-denial-of-service-in-multipart-header)
- [LangChain langchain-text-splitters SSRF redirect bypass in HTMLHeaderTextSplitter](https://junglewise.ai/threats/cve-2026-41481-langchain-langchain-text-splitters-ssrf-redirect-bypass-in)
- [NLTK path traversal in downloader component](https://junglewise.ai/threats/cve-2026-33236-nltk-path-traversal-in-downloader-component)
- [NLTK unauthenticated remote shutdown in WordNet Browser](https://junglewise.ai/threats/cve-2026-33231-nltk-unauthenticated-remote-shutdown-in-wordnet-browser)
