CVE-2026-32274: Black: Arbitrary file writes from unsanitized user input in cache file name
Impact
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.
Patches
Fixed in Black 26.3.1.
Workarounds
Do not allow untrusted user input into the value of the --python-cell-magics option.
Other sources
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.
— NVD
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.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/blackto a version that resolves this vulnerability.Fixed in 26.3.1 - Upgrade
Upgrade
blackto a version that resolves this vulnerability.Fixed in 26.3.1 - Configuration
Do not allow untrusted user input into the value of the `--python-cell-magics` option.
Black --python-cell-magics = Do not allow untrusted user input
Event History
Frequently Asked Questions
What is the severity of CVE-2026-32274?
CVE-2026-32274 has been classified as a medium severity vulnerability due to the risk of unauthorized file creation.
How do I fix CVE-2026-32274?
To fix CVE-2026-32274, upgrade the Black package to version 26.3.1 or later.
What are the potential impacts of CVE-2026-32274?
The potential impact of CVE-2026-32274 includes an attacker being able to write cache files to arbitrary locations in the file system.
Which versions of Black are affected by CVE-2026-32274?
Versions of Black prior to 26.3.1 are affected by CVE-2026-32274.
Who reported CVE-2026-32274?
CVE-2026-32274 was reported on GitHub, where the vulnerability details were disclosed by the development community.