CVE-2026-128140
NLTK downloader infinite loop via cyclic collection index causing DoS.
- CVSS 6.5
- CWE-835
- Resource Management
- Remote
NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. From 3.6.7 until 3.10.4, nltk.downloader follows collection membership without tracking already visited collection nodes. A self-referencing or mutually referencing collection index can therefore make the package-closure walk loop indefinitely while its queue and memory usage grow, denying service when a victim processes the attacker-influenced index. This issue is fixed in version 3.10.4.
- CWE
- CWE-835
- CVSS base score
- 6.5
- Published
- 2026-11-19
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Resource Management
- Subcategory
- Memory Leaks
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- NLTK
- Fixed by upgrading
- Yes
Solution
Upgrade NLTK to version 3.10.4 or newer.
Vulnerable code sample
import nltk
from nltk.downloader import Downloader
def collect_packages(index_url: str):
"""Download all packages reachable from a collection index."""
dl = Downloader()
# VULNERABLE: collection walk without visited tracking can loop forever
queue = [index_url] # start with the root collection
while queue:
url = queue.pop(0)
collection = dl._download_collection(url) # internal call returning dict with 'packages' and 'collections'
for pkg in collection.get('packages', []):
dl._download(pkg) # download individual package
# enqueue referenced collections without checking if already seen
queue.extend(collection.get('collections', []))Patched code sample
import nltk
from nltk.downloader import Downloader
def collect_packages(index_url: str):
"""Download all packages reachable from a collection index."""
dl = Downloader()
# FIX: track visited collections to avoid infinite loops
queue = [index_url]
visited = set()
while queue:
url = queue.pop(0)
if url in visited:
continue
visited.add(url)
collection = dl._download_collection(url)
for pkg in collection.get('packages', []):
dl._download(pkg)
queue.extend(collection.get('collections', []))Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Prevent infinite loop from cyclic collection indices (nltk/nltk)
nltk/downloader.py,nltk/downloader.py · Downloader._update_index
Cite this entry
@misc{vaitp:cve2026128140,
title = {{NLTK downloader infinite loop via cyclic collection index causing DoS.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-128140},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-128140/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
