CVE-2026-78681 Overview
CVE-2026-78681 is a denial of service vulnerability in the Natural Language Toolkit (NLTK) affecting versions before 3.10.3. Multiple NLTK modules parse XML using Python's xml.etree.ElementTree, which honors entity declarations in document DTDs. Attackers can craft XML payloads with nested entity declarations that expand from hundreds of bytes to megabytes in memory, exhausting resources on the parsing host. The flaw is categorized as [CWE-776] Improper Restriction of Recursive Entity References in DTDs (Billion Laughs). Successful exploitation degrades or halts availability of services that ingest untrusted XML through NLTK.
Critical Impact
A single small XML payload processed by an affected NLTK module can exhaust memory and cause denial of service on the host.
Affected Products
- NLTK versions before 3.10.3
- Applications embedding vulnerable NLTK modules that parse XML
- Python services that ingest untrusted XML through NLTK utilities
Discovery Timeline
- 2026-08-25 - CVE-2026-78681 published to NVD
- 2026-08-26 - Last updated in NVD database
Technical Details for CVE-2026-78681
Vulnerability Analysis
NLTK uses the standard library xml.etree.ElementTree module to parse XML inputs in several components. The parser processes document type declarations (DTDs) and expands internal entity references during parsing. When entities recursively reference other entities, the expanded output grows exponentially relative to the source document size.
An attacker who supplies an XML file with nested entity declarations forces the parser to allocate large volumes of memory. A payload of a few hundred bytes can expand to hundreds of megabytes, triggering resource exhaustion. The condition matches the classic "billion laughs" pattern described in [CWE-776].
The vulnerability requires no authentication and no user interaction when the affected code path processes attacker-controlled XML over the network. Confidentiality and integrity are not affected; the impact is limited to availability.
Root Cause
The root cause is the use of an XML parser configuration that honors DTD entity declarations without limiting entity expansion depth or output size. xml.etree.ElementTree in affected Python versions does not restrict entity expansion by default in the code paths NLTK invokes, allowing recursive entity references to consume unbounded memory.
Attack Vector
Exploitation requires delivering a crafted XML document to a service or workflow that parses XML through an affected NLTK module. Any network-reachable endpoint that accepts XML input and processes it through NLTK is a viable target. See the GitHub Security Advisory GHSA-97qj-x29f-37w7 and the VulnCheck Advisory on Entity Expansion DoS for technical details of the payload structure.
Detection Methods for CVE-2026-78681
Indicators of Compromise
- Sudden spikes in memory consumption by Python processes that load NLTK
- Python worker processes terminated by the out-of-memory killer while parsing XML
- Inbound XML documents containing multiple nested <!ENTITY> declarations referencing one another
Detection Strategies
- Inspect ingested XML for recursive entity declarations and reject documents that exceed entity expansion thresholds
- Enumerate deployed Python environments and flag installations of nltk with a version below 3.10.3
- Alert on abnormal process memory growth or restarts of services that invoke NLTK XML parsing routines
Monitoring Recommendations
- Track resident set size and CPU utilization of Python services that process external XML inputs
- Log XML parsing errors and abnormal termination events from NLTK-based workers
- Monitor request patterns for repeated submissions of small XML payloads followed by service degradation
How to Mitigate CVE-2026-78681
Immediate Actions Required
- Upgrade NLTK to version 3.10.3 or later in all Python environments
- Audit application code for calls into NLTK modules that parse XML and validate the source of input
- Reject or sanitize XML inputs that contain DTDs when parsing untrusted content
Patch Information
The issue is resolved in NLTK 3.10.3. Refer to the GitHub Security Advisory GHSA-97qj-x29f-37w7 for fix details and affected modules.
Workarounds
- Replace xml.etree.ElementTree usage with defusedxml when parsing untrusted XML in wrapper code
- Enforce size limits on inbound XML documents at the application or gateway layer
- Isolate NLTK XML processing in workers with strict memory limits and automatic restart policies
# Configuration example
pip install --upgrade "nltk>=3.10.3"
pip install defusedxml
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

