CVE-2026-78681: NLTK: Entity-expansion DoS (billion laughs) via remaining raw ElementTree parses
Several XML parsing sites in NLTK still used xml.etree.ElementTree directly, which honours <!ENTITY> declarations in a document’s internal DTD subset. A crafted document a few hundred bytes long can expand to megabytes in memory (each nesting level multiplies by ten), a denial-of-service.
Affected call sites (<= 3.10.2):
nltk.chunk.named_entity.load_ace_file— parses ACE annotation XMLnltk.internals.ElementWrapper— converts any given string to an Elementnltk.downloader—Package.fromxml,Collection.fromxml,_find_collections,_find_packages
libexpat 2.6.0 added an input-amplification cap, but it only engages above an activation threshold (~8 MiB output) and depends on whichever libexpat the interpreter links; builds against older libexpat have no cap at all. External entities are not resolved by ElementTree, so this is a memory-amplification DoS (CWE-776), not XXE/file disclosure.
This completes the earlier defusedxml adoption that these sites were missed by. Fix routes all of them through a new nltk.xmlsec module that refuses entity declarations, preferring defusedxml and falling back to a standard-library xml.parsers.expat pre-scan when defusedxml is absent.
References
- github.com/advisories/GHSA-97qj-x29f-37w7
- github.com/nltk/nltk/commit/e91789c9a043296ad04912ce171c22776d45963b
- github.com/nltk/nltk/releases/tag/v3.10.3
- github.com/nltk/nltk/security/advisories/GHSA-97qj-x29f-37w7
- github.com/pypa/advisory-database/tree/main/vulns/nltk/PYSEC-2026-3748.yaml
- nvd.nist.gov/vuln/detail/CVE-2026-78681
- www.vulncheck.com/advisories/nltk-before-entity-expansion-dos-via-elementtree
Code Behaviors & Features
Detect and mitigate CVE-2026-78681 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →