Junglewise Threat Intelligence

CVE-2026-78681: NLTK entity-expansion denial of service via ElementTree parsing

CVE-2026-78681 · Severity: high · CVSS 8.7 · Published 2026-09-08

Executive brief

NLTK is a popular natural language processing library that includes XML parsing functionality used to load linguistic data and packages. Multiple code paths within NLTK still used unsafe XML parsing that honours entity declarations, allowing an attacker to craft small XML files that expand to megabytes in memory, exhausting system resources and causing service denial. This affects users who process untrusted XML input through NLTK's ACE file loader, package downloader, or general-purpose XML wrapper functions.

Technical details

NLTK versions ≤3.10.2 contain multiple XML parsing code paths that directly use xml.etree.ElementTree, which honours <!ENTITY> declarations in document DTDs. An attacker can craft a small XML file (330 bytes) containing nested entity declarations that expand exponentially in memory—each nesting level multiplies by ~10, allowing a 330-byte payload to expand to ~1 MB. The vulnerable code paths include nltk.chunk.named_entity.load_ace_file(), nltk.internals.ElementWrapper(), and nltk.downloader's Package.fromxml() and Collection.fromxml() methods. While libexpat 2.6.0+ implements an input-amplification cap, it only engages above an ~8 MiB threshold and depends on the interpreter's libexpat version; older libexpat builds have no protection. The vulnerability is a memory-amplification denial of service (CWE-776); external entities are not resolved by ElementTree, so XXE/file disclosure is not possible. The fix introduces a new nltk.xmlsec module that blocks entity declarations by preferring defusedxml (when installed) and falling back to a safe xml.parsers.expat pre-scan that detects DOCTYPE declarations with entity declarations.

Affected products

  • NLTK NLTK <= 3.10.2

Timeline

  • 2026-08-11: disclosed
  • 2026-08-10: patched: Fix committed in v3.10.3
  • 2026-09-08: advisory: Published to GitHub Advisory Database

References

Related threats