Skip to main content

Black CVE-2026-32274

HIGH
Path Traversal (CWE-22)
2026-03-12 security-advisories@github.com GHSA-3936-cmfr-pm3m
8.7
CVSS 4.0 · Vendor: github
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Inject crafted --python-cell-magics value
  2. Delivery
    Value embedded unsanitized in cache filename
  3. Exploit
    Path traversal escapes cache directory
  4. Execution
    Black writes cache to attacker path
  5. Impact
    Arbitrary 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.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv5 – 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)
v4 Jun 30, 2026 - 04:54 cvss changed CVSS 8.7

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.

v3 Jun 30, 2026 - 04:52 cvss changed CVSS 8.7

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.

v2 Jun 30, 2026 - 04:52 cvss changed CVSS 8.7

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.

v1 Mar 12, 2026 - 22:55 CVSS 7.5

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

pypi black fix: 26.3.1

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

Vendor (github) PRIMARY 8.7 HIGH
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
vuln.today AI 7.5 HIGH

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.

3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
4.0 AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N
SUSE 7.5 HIGH
AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
Red Hat 7.5 HIGH

Primary rating from Vendor (github).

CVSS VectorVendor: github

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
High
Vulnerable system: Availability
None
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

7
Analysis Updated
Jun 30, 2026 - 04:55 vuln.today
v5 - CVSS changed
Analysis Updated
Jun 30, 2026 - 04:54 vuln.today
v4 - CVSS changed
Analysis Updated
Jun 30, 2026 - 04:52 vuln.today
v3 - CVSS changed
Analysis Updated
Jun 30, 2026 - 04:52 vuln.today
v2 - CVSS changed
CVSS changed
Jun 30, 2026 - 03:24 NVD
7.5 (HIGH) 8.7 (HIGH)
Patch released
Mar 31, 2026 - 21:13 nvd
Patch available
CVE Published
Mar 12, 2026 - 20:16 nvd
HIGH 7.5

DescriptionCVE.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

Why It Matters

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).

Business Impact: Low
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

EPSS Score
0.0%
Top 95% exploitable
Prevalence
High
de facto standard Python code formatter, very widely used in dev and CI
Threat Intel
1
1 source
Data Quality
6 sources
Confidence: High
NVD CVE.org EPSS GHSA Vendor GitHub VulDB

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.

SignalValue
Severity HIGH
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
Yes
Human Impact
Low

Priority Score

44
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +44
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

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

cpe:2.3:a:python:black:*:*:*:*:*:python:*:*

Vendor 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

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy