CVE-2026-32274: Black Arbitrary File Writes From Unsanitized Vulnerability
HIGHCVE-2026-32274 is a HIGH (CVSS 7.5) arbitrary file writes from unsanitized vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Black libraries in the PyPI ecosystem. The issue involves arbitrary file writes from unsanitized user input in cache file name. Remediation is available by upgrading affected packages to version 26.3.1.
CVE-2026-32274 at a Glance
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:H/A:N).
How to Fix CVE-2026-32274
To remediate this vulnerability, upgrade all affected Black dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install black>=26.3.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show black
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-32274, inspect your installed packages using pip:
pip show black
Analyze the terminal output to locate any version of Black in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 26.3.1), your application is affected.
Note: The pip show black command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Black, 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
CVE-2026-32274 Affected Black Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
black
|
PyPI |
≥ 24.3.0
< 26.3.1
|
26.3.1
|
References
Frequently Asked Questions
What is CVE-2026-32274?
Which Black versions are affected?
What version fixes CVE-2026-32274?
Is black affected?
What is the CVSS score of CVE-2026-32274?
What CWE is associated with CVE-2026-32274?
How can I check PyPI dependencies for CVE-2026-32274?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3936-cmfr-pm3m",
"modified" : "2026-08-03T20:35:16Z",
"published" : "2026-03-12T18:33:10Z",
"aliases" : [ "CVE-2026-32274" ],
"summary" : "Black: Arbitrary file writes from unsanitized user input in cache file name",
"details" : "### Impact\n\nBlack 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. \n\n### Patches\n\nFixed in Black 26.3.1.\n\n### Workarounds\n\nDo not allow untrusted user input into the value of the `--python-cell-magics` option.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
}, {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "black"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "24.3.0"
}, {
"fixed" : "26.3.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/psf/black/security/advisories/GHSA-3936-cmfr-pm3m"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-32274"
}, {
"type" : "WEB",
"url" : "https://github.com/psf/black/pull/4176"
}, {
"type" : "WEB",
"url" : "https://github.com/psf/black/pull/5038"
}, {
"type" : "WEB",
"url" : "https://github.com/psf/black/commit/4937fe6cf241139ddbfc16b0bdbb5b422798909d"
}, {
"type" : "WEB",
"url" : "https://github.com/psf/black/commit/ed770ba4dd50c419148a0fca2b43937a7447e1f9"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/errata/RHSA-2026:10184"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/errata/RHSA-2026:13545"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/errata/RHSA-2026:13553"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/security/cve/CVE-2026-32274"
}, {
"type" : "WEB",
"url" : "https://bugzilla.redhat.com/show_bug.cgi?id=2447111"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/psf/black"
}, {
"type" : "WEB",
"url" : "https://github.com/psf/black/releases/tag/26.3.1"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/black/PYSEC-2026-2121.yaml"
}, {
"type" : "WEB",
"url" : "https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-32274.json"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-12T18:33:10Z",
"nvd_published_at" : "2026-03-12T20:16:06Z"
}
}