CVE-2024-21503
JSON

5.3medium

Black vulnerable to Regular Expression Denial of Service (ReDoS)

Severity
5.3medium CVSS:3.1 by snyk
Exploit likelihood
0.98% (higher than 63% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
snyk
Also known as
GHSA-fj7x-q9j7-g6q6PYSEC-2024-48

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

Product or packageVersionsReported by
blackbefore 24.3.0CVE List
python_software_foundation blackbefore 24.3.0CVE List
black (PyPI)before 24.3.0, before f00093672628d212b8965a8993cee8bedf5fe9b8GitHub Advisory Database, PyPA Advisory Database

All scores

snyk5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L/E:P
GitHub5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Classification

CWE-75CWE-1333

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.

What each source says

CVE List

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.

NVD (es)

Las versiones del paquete black anteriores a la 24.3.0 son vulnerables a la denegación de servicio de expresión regular (ReDoS) a través de la funciónlines_with_leading_tabs_expanded en el archivo strings.py. Un atacante podría aprovechar esta vulnerabilidad creando una entrada maliciosa que provoque una denegación de servicio. Es posible explotar esta vulnerabilidad cuando se ejecuta Black en entradas que no son de confianza o si habitualmente coloca miles de caracteres de tabulación iniciales en sus cadenas de documentación.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-21503 changed 2024-08-01CVE Terms of Use
GitHub Advisory DatabaseGHSA-fj7x-q9j7-g6q6 changed 2026-09-10CC-BY-4.0
NVDCVE-2024-21503 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2024-48 changed 2026-06-10CC-BY-4.0