Vulnerability · Published Mar 19, 2024 · Assigned by snyk
CVE-2024-21503
Medium 5.3
In plain English
A medium-severity regular-expression denial of service in black. Proof-of-concept exploit code is public. The chance it is exploited in the next 30 days is estimated at 1.0% (higher than 62% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
Official description
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.
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Alpine:v3.20 | black | 24.3.0-r0 | ALPINE-CVE-2024-21503 |
| Alpine:v3.21 | black | 24.3.0-r0 | ALPINE-CVE-2024-21503 |
| Alpine:v3.22 | black | 24.3.0-r0 | ALPINE-CVE-2024-21503 |
| Alpine:v3.23 | black | 24.3.0-r0 | ALPINE-CVE-2024-21503 |
| Alpine:v3.24 | black | 24.3.0-r0 | ALPINE-CVE-2024-21503 |
| Debian:12 | black | no fix listed | DEBIAN-CVE-2024-21503 |
| Debian:13 | black | 24.4.0-1 | DEBIAN-CVE-2024-21503 |
| Debian:14 | black | 24.4.0-1 | DEBIAN-CVE-2024-21503 |
| PyPI | black | 24.3.0 | PYSEC-2024-48 |
| PyPI | black | 24.3.0 | GHSA-fj7x-q9j7-g6q6 |
| Ubuntu:22.04:LTS | black | no fix listed | UBUNTU-CVE-2024-21503 |
| Ubuntu:24.04:LTS | black | no fix listed | UBUNTU-CVE-2024-21503 |
| Ubuntu:25.10 | black | no fix listed | UBUNTU-CVE-2024-21503 |
| Ubuntu:26.04:LTS | black | no fix listed | UBUNTU-CVE-2024-21503 |
| Ubuntu:26.10 | black | no fix listed | UBUNTU-CVE-2024-21503 |
Affected products (as reported)
Weakness: CWE-1333, CWE-75 · Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L/E:P