black — security advisory
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.
- Products
- black
- Affected versions
- 19.3b0-1, 20.8b1-4, 21.10b0-1, 21.12b0-1, 21.4b2-3, 23.10.1-1, 23.11.0-1, 23.7.0-1, 24.2.0-1ubuntu1, 25.1.0-2, 25.1.0-3, 25.11.0-1, 25.12.0-1, 25.9.0-1, 26.1.0-1, 26.1.0-1build1, 26.3.1-1, 26.5.1-1
- Fixed versions
- Not specified
- CVEs
- CVE-2024-21503
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 31 Oct 2026, 01:44 UTC · Revision 1
Source evidence
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.
osv:UBUNTU-CVE-2024-21503
black
Fixed versions: Not specified
black
Fixed versions: Not specified
black
Fixed versions: Not specified
black
Fixed versions: Not specified
black
Fixed versions: Not specified
black
Fixed versions: Not specified
Complete source record
{
"id": "206006ea4989c5a15d981dd01baea2115b595b9c014ea3dfde68454f04fc981b",
"url": "https://osv.dev/vulnerability/UBUNTU-CVE-2024-21503",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "UBUNTU-CVE-2024-21503",
"summary": "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.",
"evidence": "osv:UBUNTU-CVE-2024-21503",
"products": [
{
"name": {
"value": "black",
"evidence": "/affected/0/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "19.3b0-1",
"evidence": "/affected/0/versions"
}
]
},
{
"name": {
"value": "black",
"evidence": "/affected/1/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "20.8b1-4",
"evidence": "/affected/1/versions"
},
{
"value": "21.4b2-3",
"evidence": "/affected/1/versions"
},
{
"value": "21.10b0-1",
"evidence": "/affected/1/versions"
},
{
"value": "21.12b0-1",
"evidence": "/affected/1/versions"
}
]
},
{
"name": {
"value": "black",
"evidence": "/affected/2/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "23.7.0-1",
"evidence": "/affected/2/versions"
},
{
"value": "23.10.1-1",
"evidence": "/affected/2/versions"
},
{
"value": "23.11.0-1",
"evidence": "/affected/2/versions"
},
{
"value": "24.2.0-1ubuntu1",
"evidence": "/affected/2/versions"
}
]
},
{
"name": {
"value": "black",
"evidence": "/affected/3/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "25.1.0-2",
"evidence": "/affected/3/versions"
},
{
"value": "25.1.0-3",
"evidence": "/affected/3/versions"
}
]
},
{
"name": {
"value": "black",
"evidence": "/affected/4/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "26.3.1-1",
"evidence": "/affected/4/versions"
},
{
"value": "26.5.1-1",
"evidence": "/affected/4/versions"
}
]
},
{
"name": {
"value": "black",
"evidence": "/affected/5/package/name"
},
"prerequisites": [],
"fixed_versions": [],
"affected_versions": [
{
"value": "25.1.0-3",
"evidence": "/affected/5/versions"
},
{
"value": "25.9.0-1",
"evidence": "/affected/5/versions"
},
{
"value": "25.11.0-1",
"evidence": "/affected/5/versions"
},
{
"value": "25.12.0-1",
"evidence": "/affected/5/versions"
},
{
"value": "26.1.0-1",
"evidence": "/affected/5/versions"
},
{
"value": "26.1.0-1build1",
"evidence": "/affected/5/versions"
},
{
"value": "26.3.1-1",
"evidence": "/affected/5/versions"
}
]
}
],
"severity": "medium",
"structured": {
"id": "UBUNTU-CVE-2024-21503",
"aliases": [
"UBUNTU-CVE-2024-21503"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
},
{
"type": "Ubuntu",
"score": "medium"
}
],
"affected": [
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "black",
"purl": "pkg:deb/ubuntu/black?arch=source&distro=focal",
"ecosystem": "Ubuntu:20.04:LTS"
},
"versions": [
"19.3b0-1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2024/UBUNTU-CVE-2024-21503.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "black",
"binary_version": "19.3b0-1"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "black",
"purl": "pkg:deb/ubuntu/black?arch=source&distro=jammy",
"ecosystem": "Ubuntu:22.04:LTS"
},
"versions": [
"20.8b1-4",
"21.4b2-3",
"21.10b0-1",
"21.12b0-1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2024/UBUNTU-CVE-2024-21503.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "black",
"binary_version": "21.12b0-1"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "black",
"purl": "pkg:deb/ubuntu/black?arch=source&distro=noble",
"ecosystem": "Ubuntu:24.04:LTS"
},
"versions": [
"23.7.0-1",
"23.10.1-1",
"23.11.0-1",
"24.2.0-1ubuntu1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2024/UBUNTU-CVE-2024-21503.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "black",
"binary_version": "24.2.0-1ubuntu1"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "black",
"purl": "pkg:deb/ubuntu/black?arch=source&distro=questing",
"ecosystem": "Ubuntu:25.10"
},
"versions": [
"25.1.0-2",
"25.1.0-3"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2024/UBUNTU-CVE-2024-21503.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "black",
"binary_version": "25.1.0-3"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "black",
"purl": "pkg:deb/ubuntu/black?arch=source&distro=stonking",
"ecosystem": "Ubuntu:26.10"
},
"versions": [
"26.3.1-1",
"26.5.1-1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2024/UBUNTU-CVE-2024-21503.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "black",
"binary_version": "26.5.1-1"
}
]
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
}
]
}
],
"package": {
"name": "black",
"purl": "pkg:deb/ubuntu/black?arch=source&distro=resolute",
"ecosystem": "Ubuntu:26.04:LTS"
},
"versions": [
"25.1.0-3",
"25.9.0-1",
"25.11.0-1",
"25.12.0-1",
"26.1.0-1",
"26.1.0-1build1",
"26.3.1-1"
],
"database_specific": {
"source": "https://github.com/canonical/ubuntu-security-notices/blob/main/osv/cve/2024/UBUNTU-CVE-2024-21503.json"
},
"ecosystem_specific": {
"binaries": [
{
"binary_name": "black",
"binary_version": "26.3.1-1"
}
]
}
}
],
"modified": "2026-10-17T12:57:22.978311281Z",
"provider": "osv",
"upstream": [
"CVE-2024-21503"
],
"references": [
"https://ubuntu.com/security/CVE-2024-21503",
"https://security.snyk.io/vuln/SNYK-PYTHON-BLACK-6256273",
"https://github.com/psf/black/releases/tag/24.3.0",
"https://github.com/psf/black/commit/f00093672628d212b8965a8993cee8bedf5fe9b8",
"https://www.cve.org/CVERecord?id=CVE-2024-21503"
]
},
"related_cves": [
{
"value": "CVE-2024-21503",
"evidence": "/upstream"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 357380,
"published_at": "2024-03-19T05:15:00+00:00"
}