CVE-2026-81723 in NLTK
Summary
by MITRE • 08/27/2026
NLTK versions before 3.10.3 contain a quadratic CPU exhaustion vulnerability in XMLCorpusView._read_xml_fragment() that rescans accumulated XML fragments on every 1 KiB block read. Attackers can provide malformed XML corpus files to cause severe CPU consumption and denial of service through affected readers like BNCCorpusReader.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 08/27/2026
The Natural Language Toolkit, commonly known as NLTK, is a widely used Python library for symbolic and statistical natural language processing. It provides easy-to-use interfaces to over fifty corpora and lexical resources such as WordNet, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning. Within this ecosystem, the XMLCorpusView class serves as a critical component for reading and parsing XML-based corpus files. This class is utilized by various specific corpus readers, including BNCCorpusReader which accesses data from the Brown National Corpus of American English. The integrity and performance of these readers are paramount for researchers and developers relying on NLTK for linguistic analysis and machine learning tasks involving large textual datasets.
A significant vulnerability has been identified in versions of NLTK prior to 3.10.3, specifically within the XMLCorpusView._read_xml_fragment() method. This flaw manifests as a quadratic CPU exhaustion issue, which is a form of algorithmic complexity attack. The technical root cause lies in how the parser handles incremental reading of XML data. When processing an XML corpus file, NLTK reads data in blocks, typically sized at 1 KiB. For every new block read, the _read_xml_fragment() function rescans all previously accumulated XML fragments to maintain state and ensure proper parsing continuity. This design choice means that as the size of the input file increases, the amount of work required for each subsequent block grows linearly with respect to the total data already processed. Consequently, if an attacker provides a malformed or specifically crafted large XML corpus file, the CPU usage does not scale linearly but rather quadratically relative to the file size and content structure.
The operational impact of this vulnerability is severe denial of service through resource exhaustion. Because the computational cost increases exponentially with input size, processing even moderately sized malicious files can consume nearly all available CPU resources on the host system. This leads to a complete halt in normal operations for any process relying on NLTK or the underlying operating system if other processes are not prioritized correctly. In cloud environments or shared hosting scenarios where resource limits are enforced, this could trigger automatic termination of instances due to exceeding CPU credits or time quotas. For applications that ingest user-uploaded corpus data without strict size limitations or input validation, an attacker can exploit this flaw remotely by submitting a crafted XML file via the application interface, thereby causing service disruption for all users sharing the infrastructure.
This vulnerability aligns with CWE-400, which describes Uncontrolled Resource Consumption, specifically falling under scenarios where algorithmic complexity allows attackers to cause denial of service through excessive resource usage rather than buffer overflows or memory leaks. From a threat intelligence perspective, this behavior is consistent with techniques observed in ATT&CK technique T1496, Resource Hijacking, where adversaries use computing resources for their own benefit or to disrupt services by exhausting system capacity. The attack vector typically involves Remote Code Execution prerequisites being absent; instead, the attacker relies on social engineering or automated submission mechanisms to get the victim application to parse the malicious file.
Mitigation strategies primarily involve upgrading to NLTK version 3.10.3 or later, where this quadratic complexity issue has been resolved through algorithmic optimizations that prevent unnecessary rescanning of accumulated fragments. For organizations unable to immediately upgrade their dependencies due to compatibility constraints with other software components, defensive measures should include implementing strict input validation and size limits on any XML corpus files accepted by applications using NLTK. Additionally, deploying resource monitoring tools can help detect anomalous CPU spikes indicative of such attacks in real-time. Developers integrating NLTK into production systems must also ensure that they are not passing untrusted data directly to corpus readers without sanitization or sandboxing the execution environment to limit potential damage from algorithmic complexity exploits.