Black: Arbitrary file writes from unsanitized user input in cache file name
Published 12 Mar 2026 · Updated 10 Sept 2026
Is your project on an affected black?
Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- >=24.3.0 <26.3.1
- Fixed in
- 26.3.1
pip install 'black>=26.3.1'Details
Impact
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.
Patches
Fixed in Black 26.3.1.
Workarounds
Do not allow untrusted user input into the value of the --python-cell-magics option.
Is GHSA-3936-cmfr-pm3m in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected black, and gives you the command that fixes it.
More advisories for black
- HighCVE-2026-114134Black: GitHub Action installs unvalidated required-version from pyproject.toml · 22 Oct 2026
- LowCVE-2026-31900No summary published · 11 Mar 2026
- MediumCVE-2024-21503Black vulnerable to Regular Expression Denial of Service (ReDoS) · 19 Mar 2024
References
- Linkgithub.com/psf/black/security/advisories/GHSA-3936-cmfr-pm3m
- Advisorynvd.nist.gov/vuln/detail/CVE-2026-32274
- Linkgithub.com/psf/black/pull/4176
- Linkgithub.com/psf/black/pull/5038
- Linkgithub.com/psf/black/commit/4937fe6cf241139ddbfc16b0bdbb5b422798909d
- Linkgithub.com/psf/black/commit/ed770ba4dd50c419148a0fca2b43937a7447e1f9
- Linkaccess.redhat.com/errata/RHSA-2026:10184
- Linkaccess.redhat.com/errata/RHSA-2026:13545
- Linkaccess.redhat.com/errata/RHSA-2026:13553
- Linkaccess.redhat.com/security/cve/CVE-2026-32274
- Linkbugzilla.redhat.com/show_bug.cgi?id=2447111
- Packagegithub.com/psf/black
- Linkgithub.com/psf/black/releases/tag/26.3.1
- Linkgithub.com/pypa/advisory-database/tree/main/vulns/black/PYSEC-2026-2121.yaml
- Linksecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-32274.json
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.