Vulnerabilities in pkg:pypi/black

PACKAGE
Advisory Identifier: GHSA-3936-cmfr-pm3m
Advisory Summary

CVE-2026-32274 is a HIGH (CVSS 7.5) arbitrary file writes from unsanitized vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Black libraries in the PyPI ecosystem. The issue involves arbitrary file writes from unsanitized user input in cache file name. Remediation is available by upgrading affected packages to version 26.3.1.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/black

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/black. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-3936-cmfr-pm3m CVE-2026-32274 HIGH Black: Arbitrary file writes from unsanitized user input in cache file name
GHSA-fj7x-q9j7-g6q6 CVE-2024-21503 MODERATE Black vulnerable to Regular Expression Denial of Service (ReDoS)

CVE-2026-32274 at a Glance

CVE Identifier CVE-2026-32274
GHSA Identifier GHSA-3936-cmfr-pm3m
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Black
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-32274

To remediate this vulnerability, upgrade all affected Black dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

black fixed: 26.3.1
pip install black>=26.3.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show black

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-32274, inspect your installed packages using pip:

pip show black

Analyze the terminal output to locate any version of Black in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 26.3.1), your application is affected.

Note: The pip show black command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Black, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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

CVE-2026-32274 Affected Black Versions

1 component(s)
Fixed Versions:
26.3.1
Product / Package Ecosystem Affected Versions Fixed Version
black
PyPI
≥ 24.3.0
< 26.3.1
26.3.1

References

Frequently Asked Questions

What is CVE-2026-32274?
CVE-2026-32274 is a security vulnerability in Black involving Arbitrary file writes from unsanitized user input in cache file name under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Black versions are affected?
Affected versions include releases prior to 26.3.1 across affected packages: black.
What version fixes CVE-2026-32274?
Upgrading to 26.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is black affected?
Yes, black is affected in releases prior to 26.3.1. Upgrade your dependency to 26.3.1 or later.
What is the CVSS score of CVE-2026-32274?
CVE-2026-32274 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2026-32274?
CVE-2026-32274 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2026-32274?
Run the dependency tree command: 'pip show black'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3936-cmfr-pm3m",
  "modified" : "2026-08-03T20:35:16Z",
  "published" : "2026-03-12T18:33:10Z",
  "aliases" : [ "CVE-2026-32274" ],
  "summary" : "Black: Arbitrary file writes from unsanitized user input in cache file name",
  "details" : "### Impact\n\nBlack 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. \n\n### Patches\n\nFixed in Black 26.3.1.\n\n### Workarounds\n\nDo not allow untrusted user input into the value of the `--python-cell-magics` option.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "black"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "24.3.0"
      }, {
        "fixed" : "26.3.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/psf/black/security/advisories/GHSA-3936-cmfr-pm3m"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-32274"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/psf/black/pull/4176"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/psf/black/pull/5038"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/psf/black/commit/4937fe6cf241139ddbfc16b0bdbb5b422798909d"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/psf/black/commit/ed770ba4dd50c419148a0fca2b43937a7447e1f9"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2026:10184"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2026:13545"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2026:13553"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/security/cve/CVE-2026-32274"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=2447111"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/psf/black"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/psf/black/releases/tag/26.3.1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/black/PYSEC-2026-2121.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-32274.json"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-12T18:33:10Z",
    "nvd_published_at" : "2026-03-12T20:16:06Z"
  }
}