# NLTK entity-expansion denial of service via ElementTree XML parsing

Source: https://junglewise.ai/threats/nltk-entity-expansion-denial-of-service-via-elementtree-xml-parsing-e2038a9e  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-08-25. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

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

NLTK is a widely-used Python library for natural language processing that includes XML parsing capabilities. A flaw in how it handles XML documents allows attackers to send specially crafted XML payloads that consume excessive memory when parsed, crashing applications that use NLTK. An attacker can exploit this remotely without authentication by submitting a small XML file that expands to consume megabytes of memory, disrupting service availability.

Technologies: [nltk (PyPI)](https://junglewise.ai/threats/technologies/nltk). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** High severity, with a CVSS score of 7.5, published 25 August 2026.

**Which products and versions are affected?** nltk (PyPI) <= 3.10.2.

**Is there a fix for This vulnerability?** A patch was published on 2026: Fix available in version 3.10.3 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network, in a software library.

**Am I affected?** 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.

## Technical details

The vulnerability is an XML Entity Expansion attack (CWE-776, "billion laughs") affecting multiple NLTK call sites that use xml.etree.ElementTree directly: nltk.chunk.named_entity.load_ace_file, nltk.internals.ElementWrapper, nltk.downloader (Package.fromxml, Collection.fromxml), and related functions. The root cause is that ElementTree honors entity declarations in DTD subsets without restriction. Attackers craft payloads with nested entity declarations where each nesting level multiplies output by approximately 10 while adding minimal input bytes—a payload of ~330 bytes can expand to 1 MB in memory. External entities are not resolved so this is memory-amplification DoS rather than XXE file disclosure. Attack vector is network-based with no authentication or user interaction required. The fix routes all affected parsing sites through a new nltk.xmlsec module that refuses entity declarations, using defusedxml with a fallback to xml.parsers.expat pre-scan. Patched in version 3.10.3.

## Affected products

- NLTK Project NLTK < 3.10.3

## Timeline

- 2026-08-11: disclosed: Original advisory GHSA-97qj-x29f-37w7 published
- 2026-08-25: advisory: Duplicate advisory GHSA-jx89-3qg8-p2mr published and later withdrawn
- 2026: patched: Fix available in version 3.10.3

## References

- [https://github.com/nltk/nltk/security/advisories/GHSA-97qj-x29f-37w7](https://github.com/nltk/nltk/security/advisories/GHSA-97qj-x29f-37w7)
- [https://www.vulncheck.com/advisories/nltk-before-entity-expansion-dos-via-elementtree](https://www.vulncheck.com/advisories/nltk-before-entity-expansion-dos-via-elementtree)

## Related threats

- [NLTK WekaClassifier path traversal in model validation](https://junglewise.ai/threats/cve-2026-109956-nltk-through-3-10-3-contains-a-path-traversal-vulnerability-in)
- [NLTK RecursiveDescentParser uncontrolled recursion denial of service](https://junglewise.ai/threats/cve-2026-12876-nltk-recursivedescentparser-uncontrolled-recursion-denial-of)
- [NLTK tgrep regular expression denial of service](https://junglewise.ai/threats/nltk-tgrep-regular-expression-denial-of-service-02fca1b2)
- [NLTK Downloader hardlink filesystem containment bypass](https://junglewise.ai/threats/nltk-downloader-hardlink-filesystem-containment-bypass-522cb97d)
- [NLTK Pl196xCorpusReader quadratic ReDoS on malformed TEI blocks](https://junglewise.ai/threats/nltk-pl196xcorpusreader-quadratic-redos-on-malformed-tei-blocks-8473e6ef)
