# CVE-2024-21503: Black vulnerable to Regular Expression Denial of Service (ReDoS)

Source: https://junglewise.ai/threats/cve-2024-21503-black-vulnerable-to-regular-expression-denial-of-service-redos  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2024-03-19  
License: CC BY 4.0 with a link back

CVE-2024-21503 · Severity: low · CVSS 3.1 · Published 2024-03-19

Versions of the package black before 24.3.0 are vulnerable to Regular Expression Denial of Service (ReDoS) via the lines_with_leading_tabs_expanded function in the strings.py file. An attacker could exploit this vulnerability by crafting a malicious input that causes a denial of service.Exploiting this vulnerability is possible when running Black on untrusted input, or if you habitually put thousands of leading tab characters in your docstrings.

Technologies: [black (PyPI)](https://junglewise.ai/threats/technologies/pypi-black). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2024-21503 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2024-21503 being exploited in the wild.

**How severe is CVE-2024-21503?** Low severity, with a CVSS score of 3.1, published 19 March 2024.

**Which products and versions are affected?** black (PyPI) ECOSYSTEM:introduced=0,fixed=24.3.0, GIT:introduced=0,fixed=f00093672628d212b8965a8993cee8bedf5fe9b8|ECOSYSTEM:introduced=0,fixed=24.3.0.

**Is there a fix for CVE-2024-21503?** Yes. black (PyPI): upgrade to 24.3.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**Am I affected by CVE-2024-21503?** Check whether you run black (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- black (PyPI): upgrade to 24.3.0 or later

  ```sh
  pip install "black>=24.3.0"
  ```


## Affected products

- black (PyPI) ECOSYSTEM:introduced=0,fixed=24.3.0, GIT:introduced=0,fixed=f00093672628d212b8965a8993cee8bedf5fe9b8|ECOSYSTEM:introduced=0,fixed=24.3.0

## Identifiers

- CVE-2024-21503
- GHSA-fj7x-q9j7-g6q6
- PYSEC-2024-48

## Related threats

- [Black GitHub Action code injection via unvalidated required-version](https://junglewise.ai/threats/cve-2026-114134-black-github-action-installs-unvalidated-required-version-from)
- [psf Black arbitrary file write via unsanitized cache filename](https://junglewise.ai/threats/cve-2026-32274-psf-black-arbitrary-file-write-via-unsanitized-cache-filename)
- [PYSEC-2026-2120 - Black is the uncompromising Python code formatter. Black provides a GitHub action for formatting…](https://junglewise.ai/threats/cve-2026-31900-pysec-2026-2120-black-is-the-uncompromising-python-code-formatter)
