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

CVE-2026-78681 · Severity: high · CVSS 7.5 · Published 2026-08-25

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.

Technologies: nltk (PyPI). Vendors: PyPI.

Quick answers

Is CVE-2026-78681 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-78681 being exploited in the wild.
How severe is CVE-2026-78681?
High severity, with a CVSS score of 7.5, published 25 August 2026.
Which products and versions are affected?
nltk (PyPI) <= 3.10.2, ECOSYSTEM:introduced=0,fixed=3.10.3.
Is there a fix for CVE-2026-78681?
Yes. nltk (PyPI): upgrade to 3.10.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-78681 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-78681?
Check whether you run nltk (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • nltk (PyPI): upgrade to 3.10.3 or later
    pip install "nltk>=3.10.3"

Technical details

NLTK versions ≤3.10.2 contain multiple XML parsing code paths that directly use xml.etree.ElementTree, which honours &lt;!ENTITY&gt; 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

Identifiers

  • CVE-2026-78681
  • GHSA-97qj-x29f-37w7
  • PYSEC-2026-3748

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

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.