CVE-2026-32274: Black: Arbitrary file writes from unsanitized user input in cache file name

Published Mar 12, 2026
·
Updated

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

2 affected componentsFixes available
pip/black<26.3.1
26.3.1
Python Black Python<26.3.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/black to a version that resolves this vulnerability.

    Fixed in 26.3.1
  2. Upgrade

    Upgrade black to a version that resolves this vulnerability.

    Fixed in 26.3.1
  3. 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

Mar 12, 2026
Advisory Published
via GitHub·06:33 PM
Data Sourced
via GitHub·06:33 PM
DescriptionWeaknessAffected Software
CVE Published
via MITRE·07:47 PM
Data Sourced
via MITRE·07:47 PM
DescriptionWeakness
Data Sourced
via Red Hat·08:01 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·08:16 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·08:16 PM
RemedyAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

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.

2

How do I fix CVE-2026-32274?

To fix CVE-2026-32274, upgrade the Black package to version 26.3.1 or later.

3

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.

4

Which versions of Black are affected by CVE-2026-32274?

Versions of Black prior to 26.3.1 are affected by CVE-2026-32274.

5

Who reported CVE-2026-32274?

CVE-2026-32274 was reported on GitHub, where the vulnerability details were disclosed by the development community.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203