Description
Black is the uncompromising Python code formatter. Starting in version 24.3.0 and prior to version 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.
Published: 2026-03-12
Score: 8.7 High
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

Black, the Python code formatter, generates a cache file whose name is constructed from formatting options. Starting with release 24.3.0, the value passed to the --python-cell-magics option was placed directly into that filename without any sanitization. An attacker capable of controlling this argument can therefore cause Black to write a cache file to any path on the filesystem, effectively performing an uncontrolled write (CWE‑22). The potential result is corruption or replacement of arbitrary files, which can compromise system integrity and allow the injection of malicious code into trusted files.

Affected Systems

The vulnerability exists in all releases of Black from version 24.3.0 up to, but not including, 26.3.1. The affected product is the Python Software Foundation’s Black code formatter; any installation of Black older than 26.3.1 on any platform is potentially exposed.

Risk and Exploitability

The CVSS base score of 8.7 indicates a high impact vulnerability. The EPSS score of < 1 % suggests that exploitation is uncommon at present, and the issue is not listed in the CISA KEV catalog. Likely attack vectors are local or involve through command‑line or configuration manipulation, allowing an adversary to supply a crafted --python-cell-magics value. While remote exploitation is unlikely without privileged access to the Black execution environment, the ability to overwrite files remains a serious risk in contexts where Black is run with elevated privileges.

Generated by OpenCVE AI on August 5, 2026 at 03:11 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade Black to 26.3.1 or a later release.
  • If an upgrade is not immediately possible, disable or omit the --python-cell-magics option, or use it only with input that has been vetted and explicitly trusted.
  • Restrict the execution of Black to accounts with the minimum necessary privileges and monitor the filesystem for unexpected cache file creation.

Generated by OpenCVE AI on August 5, 2026 at 03:11 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-3936-cmfr-pm3m Black: Arbitrary file writes from unsanitized user input in cache file name
History

Mon, 03 Aug 2026 20:45:00 +0000

Type Values Removed Values Added
Description 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. Black is the uncompromising Python code formatter. Starting in version 24.3.0 and prior to version 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.
References

Wed, 18 Mar 2026 14:15:00 +0000

Type Values Removed Values Added
First Time appeared Python
Python black
CPEs cpe:2.3:a:python:black:*:*:*:*:*:python:*:*
Vendors & Products Python
Python black

Fri, 13 Mar 2026 16:15:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Fri, 13 Mar 2026 10:00:00 +0000

Type Values Removed Values Added
First Time appeared Psf
Psf black
Vendors & Products Psf
Psf black

Fri, 13 Mar 2026 00:15:00 +0000

Type Values Removed Values Added
References
Metrics threat_severity

None

cvssV3_1

{'score': 7.5, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N'}

threat_severity

Important


Thu, 12 Mar 2026 20:00:00 +0000

Type Values Removed Values Added
Description 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.
Title Black: Arbitrary file writes from unsanitized user input in cache file name
Weaknesses CWE-22
References
Metrics cvssV4_0

{'score': 8.7, 'vector': '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'}


cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-08-03T20:36:42.572Z

Reserved: 2026-03-11T15:05:48.400Z

Link: CVE-2026-32274

cve-icon Vulnrichment

Updated: 2026-07-15T01:08:22.759Z

cve-icon NVD

Status : Analyzed

Published: 2026-03-12T20:16:06.350

Modified: 2026-06-17T10:35:28.117

Link: CVE-2026-32274

cve-icon Redhat

Severity : Important

Publid Date: 2026-03-12T19:47:07Z

Links: CVE-2026-32274 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-08-05T03:15:05Z

Weaknesses
  • CWE-22

    Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')