CVE-2026-129232
Quadratic XML parsing in NLTK before 3.10.4 leads to DoS.
- CVSS 5.3
- CWE-400
- 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. Prior to 3.10.4, XMLCorpusView.read_block rebuilds the full root-to-node context path with "/".join(context) for every start tag while searching for a matching element. Deeply nested attacker-influenced corpus XML therefore causes quadratic pure-Python work and can pin a processing worker, resulting in denial of service. This issue is fixed in version 3.10.4.
- CWE
- CWE-400
- CVSS base score
- 5.3
- Published
- 2026-11-19
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Algorithm
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- NLTK 3.10.4
- Fixed by upgrading
- Yes
Solution
Upgrade NLTK to version 3.10.4 or newer.
Vulnerable code sample
import xml.sax
from nltk.corpus.reader.util import XMLCorpusView
class BadXMLCorpusView(XMLCorpusView):
def __init__(self, fileid, encoding='utf8'):
super().__init__(fileid, encoding)
# VULNERABLE: quadratic path reconstruction per start tag
def read_block(self, stream):
# Simplified parsing loop
context = []
for event, elem in xml.sax.parse(stream, xml.sax.handler.ContentHandler()):
if event == 'start':
context.append(elem.tag)
# Rebuild full path each time – O(n) per element
current_path = "/".join(context)
if current_path == "root/target":
return elem.text
elif event == 'end':
context.pop()
return NonePatched code sample
import xml.sax
from nltk.corpus.reader.util import XMLCorpusView
class BadXMLCorpusView(XMLCorpusView):
def __init__(self, fileid, encoding='utf8'):
super().__init__(fileid, encoding)
# FIX: maintain incremental path to avoid quadratic work
def read_block(self, stream):
context = []
path_parts = []
for event, elem in xml.sax.parse(stream, xml.sax.handler.ContentHandler()):
if event == 'start':
context.append(elem.tag)
path_parts.append(elem.tag)
# Build path incrementally – O(1) per element
current_path = "/".join(path_parts)
if current_path == "root/target":
return elem.text
elif event == 'end':
context.pop()
path_parts.pop()
return NonePublished 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.
- Bound three quadratic algorithmic-DoS vectors on untrusted input (nltk/nltk)
nltk/corpus/reader/xmldocs.py,nltk/corpus/reader/xmldocs.py · XMLCorpusView.read_block,nltk/data.py,nltk/data.py · SeekableUnicodeStreamReader.readline,nltk/redos.py,nltk/redos.py · check_pattern
Cite this entry
@misc{vaitp:cve2026129232,
title = {{Quadratic XML parsing in NLTK before 3.10.4 leads to DoS.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-129232},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129232/}}
}
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 ::
