# CVE-2026-32274: Black: Arbitrary file writes from unsanitized user input in cache file name

> An attacker controlling the --python-cell-magics argument can write cache files to arbitrary locations due to unsanitized input in the filename.

- **Severity:** High 8.7 (`CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 12 Mar 2026
- **Updated:** 3 Aug 2026
- **Also known as:** CLEANSTART-2026-XE98234, DEBIAN-CVE-2026-32274, ECHO-c5b6-7968-60af, GHSA-3936-cmfr-pm3m, MINI-rphp-3qhx-5x4v, OESA-2026-4064, PYSEC-2026-2121, ROOT-APP-PYPI-CVE-2026-32274, SUSE-SU-2026:0900-1, UBUNTU-CVE-2026-32274, openSUSE-SU-2026:11856-1

## What is CVE-2026-32274?

CVE-2026-32274 is a high-severity path traversal vulnerability in psf black, published on 12 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Black is the uncompromising Python code formatter. Starting in version 24.3.0 and prior to version 26.3.1, Black writes a cache file, the name of which is computed from various formatting options. The value of the --python-cell-magics option was placed in the filename without sanitization, which allowed an attacker who controls the value of this argument to write cache files to arbitrary file system locations. Fixed in Black 26.3.1.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2026-32274?

3 open source packages ship an affected version, including black. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `black` | PyPI | All versions | 26.3.1 |
| `black` | PyPI | From 24.3.0 | 26.3.1 |
| `black` | PyPI | From 24.3.0 | 26.3.1 |
| `python-black` | openSUSE:Leap 15.6 | All versions | 24.3.0-150400.9.11.1 |
| `ansible-lint` | openSUSE:Tumbleweed | All versions | 26.9.0-1.1 |

Products: Python Black.

## How do I fix CVE-2026-32274?

Upgrade black to 26.3.1 or later.

## Is CVE-2026-32274 being exploited?

There is no known exploitation of CVE-2026-32274 in the wild and no public exploit code.

## Other vulnerabilities in psf black

- [CVE-2026-31900](https://insights.sbomify.com/CVE-2026-31900/): Black's vulnerable version parsing leads to RCE in GitHub Action (high 8.7)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-32274 and fix it if it is affected.

What it is: CVE-2026-32274 is a high-severity path traversal vulnerability in psf black, published on 12 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2026-32274 in the wild and no public exploit code.

Affected packages and fixed versions:
- black (PyPI): affected all versions; fixed in 26.3.1
- black (PyPI): affected from 24.3.0; fixed in 26.3.1
- black (PyPI): affected from 24.3.0; fixed in 26.3.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-32274/ (Markdown: https://insights.sbomify.com/CVE-2026-32274/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-32274
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-32274
- OSV: https://osv.dev/vulnerability/CVE-2026-32274

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-32274/
Summaries are generated and may contain mistakes; the official description above is the record.
