Black
CVE-2026-32274
HIGH
Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessInject crafted --python-cell-magics value
-
DeliveryValue embedded unsanitized in cache filename
-
ExploitPath traversal escapes cache directory
-
ExecutionBlack writes cache to attacker path
-
ImpactArbitrary file create/overwrite (integrity loss)
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V5 - File Handling Path canonicalization, traversal prevention
MITRE ATT&CK
2 techniques across 2 tactics: Discovery, Collection The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Requires that the attacker control the value of Black's --python-cell-magics command-line option, AND that the Black run subsequently writes its cache (default behavior unless caching is disabled). The injected value must contain traversal/separator sequences ('..' or '/') and is used verbatim only while the combined features-and-magics string stays under the cache-key length threshold (longer values were already hashed before the fix). Limiting factors: in ordinary local use the operator sets this option themselves, so realistic exploitation is confined to multi-tenant, automated, or service-wrapped deployments where untrusted input flows into Black's CLI; the impact is an arbitrary file WRITE/overwrite (integrity), not code execution or data disclosure, and the write destination is bounded by the privileges of the user running Black. |
| Impact | Signals consistently point to LOW real-world urgency despite the 8.7 CVSS 4.0 score. The vendor vector (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N) records integrity-only impact with no confidentiality or availability loss, matching an arbitrary-file-write primitive rather than RCE. EPSS is 0.02% (5th percentile), there is no KEV listing, and no public PoC is known, so there is no evidence of active or opportunistic exploitation. The key nuance is the precondition: the attacker must control the --python-cell-magics argument, which in normal use is set by the operator running Black, not by a remote party. The published AV:N/PR:N rating therefore reflects a worst-case automation scenario (a CI job or hosted formatting service passing untrusted data into Black's CLI) rather than a typical developer workstation - verify against your own deployment. Net: a real but situational integrity issue, trivially fixed by upgrading, and low priority for environments that do not expose Black's options to untrusted input. |
| Exploit ScenarioDerived | A hosted code-formatting service or CI pipeline lets users influence Black's invocation flags and forwards a user-supplied value such as --python-cell-magics='../../../home/ci/.bashrc'. When Black runs and writes its cache, the unsanitized value steers the cache file outside the intended cache directory, letting the attacker create or overwrite a file at a chosen location. No public PoC is known, but the project's own regression test (python_cell_magics={'../../../tmp/pwned'}) demonstrates the traversal mechanism. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv5 – Jun 30, 2026
Arbitrary file write in Black (the Python code formatter) before 26.3.1 lets an attacker who controls the value of the --python-cell-magics option place cache files at attacker-chosen filesystem locations via path traversal. The unsanitized option value is embedded directly into the computed cache filename, so a value such as '../../../tmp/pwned' escapes the cache directory and overwrites or creates files elsewhere. No public exploit is identified at time of analysis, EPSS is very low (0.02%), and the issue is not in CISA KEV; practical risk is confined to environments that feed untrusted input into Black's command-line options.
Earlier versions of this analysis (4)
Path traversal arbitrary file write in the Black Python code formatter (versions prior to 26.3.1) allows an attacker who controls the value of the --python-cell-magics option to write Black's cache files to arbitrary filesystem locations. Because the option value is embedded into the computed cache filename without sanitization (CWE-22), it can escape the intended cache directory. There is no public exploit identified at time of analysis, and the EPSS score is very low (0.02%), indicating no observed exploitation interest.
Arbitrary file write in the Black Python code formatter (versions prior to 26.3.1) allows an attacker who controls the value of the --python-cell-magics command-line option to write Black's cache files to arbitrary filesystem locations. Because the unsanitized option value is embedded directly into the cache filename, path-traversal sequences (e.g. ../../) escape the intended cache directory, enabling creation or corruption of files outside it. EPSS probability is very low (0.02%, 5th percentile), there is no public exploit identified at time of analysis, and the issue is not in CISA KEV; a vendor patch is available in 26.3.1.
Arbitrary file write in Black (the Python code formatter) prior to version 26.3.1 lets an attacker who controls the --python-cell-magics option value perform path traversal: the unsanitized value is embedded into the computed cache filename, so a crafted value writes Black's cache file to an arbitrary filesystem location. This is a CWE-22 path traversal affecting integrity only; there is no public exploit identified at time of analysis and EPSS is very low (0.02%, 5th percentile). The practical risk surfaces where the option value is attacker-influenced, such as a CI/CD run formatting a repository whose configuration an attacker can set.
RemediationAI
Vendor-released patch: Black 26.3.1 - upgrade with 'pip install --upgrade "black>=26.3.1"' and update pinned versions in requirements/constraints and pre-commit hook revisions; on SUSE or Red Hat systems apply the corresponding distro updates (SUSE-SU-2026:0900 / SUSE-SU-2026:20928, RHSA-2026:10184 / RHSA-2026:13545 / RHSA-2026:13553). If you cannot upgrade immediately, the vendor workaround is to ensure untrusted input never reaches the --python-cell-magics option value; concretely, in any pipeline or service wrapping Black, hard-code or allowlist the cell-magic names and reject any value containing '/' or '..', and run Black under a low-privilege user so a stray cache write cannot clobber sensitive files (side effect: none for normal formatting, since legitimate magic names contain no path characters). These controls only close the specific argument-injection path and do not replace the upgrade. See GHSA-3936-cmfr-pm3m and https://github.com/psf/black/pull/5038.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
Black caches formatting results in a file whose name is derived from the active formatting options, including --python-cell-magics (the list of Jupyter cell-magic names Black should treat as Python). In get_cache_key()/get_cache_file() (src/black/mode.py) the joined feature-and-magics string was only SHA-256-hashed when it exceeded a maximum length; shorter values were placed in the filename verbatim. Because the magic names were not sanitized, embedded path separators ('/') and traversal sequences ('..') survived into the path, producing CWE-22 (Improper Limitation of a Pathname to a Restricted Directory / Path Traversal). The fix in PR #5038 / commit 4937fe6 unconditionally hashes the magics-derived cache-key component so no user-supplied magic name can influence the path, and adds hardening to the Jupyter magic masking/unmasking logic to prevent placeholder collisions. The affected package is the PyPI/pip distribution python:black (cpe:2.3:a:python:black).
Know when Black gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
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
Arbitrary file write yields high integrity impact with no confidentiality or availability loss; rated AV:N/PR:N to match the worst-case automated/service context where attacker input reaches the option, though local operator-only use is far more typical.
AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
Primary rating from Vendor (github).
CVSS VectorVendor: github
Lifecycle Timeline
7DescriptionCVE.org
Black is the uncompromising Python code formatter. Prior to 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.
Executive ViewAI
Black, a widely-used Python code formatter, contains a path traversal vulnerability (CVSS 8.7) that allows arbitrary file write if untrusted input is passed to the --python-cell-magics command-line option. Organizations operating automated code formatting systems that accept external input face potential file tampering or creation. The practical organizational risk remains low: no public exploit identified at time of analysis, and the attack requires specific preconditions (attacker control of CLI input).
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Path traversal exploits occur when applications use user-controlled input to construct file system paths without proper validation.
Affected Products (CPE)CVE.org
Same weakness CWE-22 – Path Traversal
View allSame technique Path Traversal
View allVendor StatusVendor
SUSE
Severity: High| Product | Status |
|---|---|
| Container suse/sl-micro/6.0/baremetal-os-container:latest Container suse/sl-micro/6.1/baremetal-os-container:2.2.1-7.67 Image SL-Micro-Base Image SL-Micro-Base-RT Image SL-Micro-Base-RT-SelfInstall Image SL-Micro-Base-RT-encrypted Image SL-Micro-Base-SelfInstall Image SL-Micro-Base-encrypted Image SL-Micro-Base-qcow Image SL-Micro-Default Image SL-Micro-Default-SelfInstall Image SL-Micro-Default-encrypted Image SL-Micro-Default-qcow Image SL-Micro-EC2 Image SUSE-Multi-Linux-Manager-Proxy-BYOS-EC2 Image SUSE-Multi-Linux-Manager-Server-Azure-ltd Image SUSE-Multi-Linux-Manager-Server-BYOS-EC2 Image SUSE-Multi-Linux-Manager-Server-EC2-llc Image SUSE-Multi-Linux-Manager-Server-EC2-ltd | Affected |
| Container suse/sl-micro/6.0/base-os-container:2.1.3-7.47 Container suse/sl-micro/6.0/toolbox:13.2-9.31 | Affected |
| SUSE Linux Enterprise Server 16.0 SUSE Linux Enterprise Server for SAP applications 16.0 | Fixed |
| openSUSE Leap 15.6 | Fixed |
| openSUSE Leap 16.0 | Fixed |
| openSUSE Tumbleweed | Fixed |
| SUSE Linux Enterprise Server 16.0 | Affected |
| SUSE Linux Enterprise Server 16.0 | Fixed |
| SUSE Linux Enterprise Server 16.1 | Fixed |
| SUSE Linux Enterprise Server for SAP applications 16.0 | Fixed |
| SUSE Linux Enterprise Server for SAP applications 16.1 | Fixed |
| openSUSE Leap 15.6 | Fixed |
| openSUSE Leap 15.4 | Fixed |
GHSA-3936-cmfr-pm3m
NVD
CVE.org
EPSS
VulDB
Exploit-DB