CVE-2026-32274
Python vulnerability analysis and mitigation

Overview

CVE-2026-32274 is a path traversal vulnerability in Black, the Python code formatter, that allows arbitrary cache file writes via an unsanitized --python-cell-magics option value. The vulnerability affects all Black versions prior to 26.3.1 and was disclosed on March 12, 2026, by researcher fg0x0. It carries a CVSS v3.1 score of 7.5 (High) and a CVSS v4.0 score of 8.7 (High) (Github Advisory, Feedly). IBM Guardium Data Security Center is also listed as an affected product (IBM Advisory).

Technical details

The root cause is CWE-22 (Improper Limitation of a Pathname to a Restricted Directory), specifically in Black's cache key generation logic within src/black/mode.py. When computing the cache filename, the value supplied to --python-cell-magics was incorporated directly into the filename string without sanitization or hashing, allowing path traversal sequences (e.g., ../../../tmp/pwned) to redirect cache file writes to arbitrary filesystem locations (Github Advisory). The fix in PR #5038 unconditionally hashes the features_and_magics component of the cache key using SHA-256, ensuring that no user-supplied value can influence the resulting file path (Black PR #5038, Black Commit). Exploitation requires that an attacker control the value passed to --python-cell-magics, which is most relevant in CI/CD pipelines, build automation, or services that invoke Black with user-supplied arguments.

Impact

Successful exploitation allows an attacker to write cache files to arbitrary locations on the filesystem accessible to the process running Black, with no authentication or user interaction required. This primarily affects integrity — an attacker could overwrite critical configuration files, inject malicious content into system directories, or corrupt application data. Confidentiality and availability are not directly impacted by this vulnerability, but file overwrite primitives can serve as a stepping stone for privilege escalation or code injection in certain deployment contexts (Github Advisory, Feedly).

Exploitability

No public proof-of-concept exploit code is known to exist, and there is no evidence of in-the-wild exploitation at this time (Feedly). The EPSS score is approximately 0.021–0.023%, placing it in the 7th percentile for exploitation likelihood within 30 days (Github Advisory). The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. No threat actor attribution has been reported. The attack vector is network-accessible with no privileges or user interaction required, making it theoretically straightforward to exploit in environments where Black is invoked with externally controlled arguments.

Exploitation steps

  1. Identify a target environment: Locate a CI/CD pipeline, web service, or automation script that invokes Black with user-controlled input passed to the --python-cell-magics option.
  2. Craft a malicious magic name: Construct a path traversal payload as the magic name value, such as ../../../tmp/pwned or a path targeting a sensitive file (e.g., ../../.ssh/authorized_keys).
  3. Inject the payload: Supply the crafted value as the --python-cell-magics argument when Black is invoked, for example: black --python-cell-magics '../../../tmp/pwned' target.py.
  4. Trigger cache file write: Black computes the cache filename using the unsanitized magic name and writes a cache file to the attacker-controlled path, potentially overwriting existing files at that location.
  5. Achieve objective: Depending on the target path and file permissions, the attacker may overwrite configuration files, inject content into writable system locations, or corrupt application state (Github Advisory, Black PR #5038).

Indicators of compromise

  • File System: Unexpected files appearing in directories outside the normal Black cache directory (typically ~/.cache/black/ or a project-local cache), especially with names resembling Black cache files but in unusual locations; files with Black cache content (JSON-formatted hash data) in system directories or sensitive paths.
  • Process: Black process (black) spawned with --python-cell-magics arguments containing path separators (/, ..) or unusual characters; Black invocations originating from web services or network-facing processes.
  • Logs: CI/CD or build system logs showing Black invocations with --python-cell-magics values containing .., /, or other path traversal sequences; file write events to unexpected directories by the Black process as recorded by auditd or similar tools.

Mitigation and workarounds

Upgrade Black to version 26.3.1 or later, which unconditionally hashes the --python-cell-magics cache key component using SHA-256, preventing path traversal (Black Release 26.3.1). As an immediate workaround where patching is not possible, do not allow untrusted user input to be passed as the value of --python-cell-magics (Github Advisory). Additionally, review and restrict how --python-cell-magics is provided in build pipelines and automation scripts, and consider implementing input validation at the application level. IBM Guardium Data Security Center users should refer to the IBM advisory for product-specific remediation guidance (IBM Advisory).

Community reactions

The vulnerability was published by Black maintainer JelleZijlstra on March 12, 2026, alongside the patched release. SUSE issued a security update for the python-black package, and openSUSE published a security announcement (openSUSE Announce). Red Hat also tracked the CVE and published a security advisory page. The vulnerability received routine coverage from Linux security news outlets and vulnerability aggregators, with no notable controversy or significant community debate observed.

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-61539CRITICAL10
  • Python logoPython
  • xinference
NoYesAug 21, 2026
CVE-2026-49360HIGH7.8
  • Python logoPython
  • recce
NoYesAug 21, 2026
CVE-2026-68508HIGH7.8
  • Python logoPython
  • hydra-core
NoYesAug 21, 2026
CVE-2026-43980MEDIUM6.3
  • Python logoPython
  • malla
NoNoAug 21, 2026
CVE-2026-55468MEDIUM4.3
  • Python logoPython
  • wagtail
NoYesAug 24, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management