GHSA-8846-P9W9-5FRF
Vulnerability from github – Published: 2026-11-19 23:53 – Updated: 2026-11-19 23:53Summary
The recursive traversal engines behind WordNetCorpusReader's Synset.tree() and Synset.acyclic_tree() have no maximum call-depth safeguard and default to unlimited depth. They guard against literal cycles, but not against a long, genuinely acyclic relation chain — which exhausts the Python call stack the same way as the sibling DependencyGraph finding I reported separately. Real-world exploitability requires the host application to load a custom/foreign WordNet-format lexical resource rather than NLTK's bundled default corpus — flagging that narrower scope honestly up front since it affects severity, not validity.
Details
nltk/util.py's acyclic_depth_first() (~lines 471-541) and acyclic_branches_depth_first() (~lines 544-625) recurse once per graph edge, default to depth=-1 ("unlimited"), and guard against re-visiting the same node via an explicit traversed set (hence "acyclic") — but that set only prevents literal cycles, it never bounds how many distinct nodes a single call chain may pass through before returning.
Synset.tree(rel, depth=-1) (nltk/corpus/reader/wordnet.py, ~line 664) calls the recursive acyclic_branches_depth_first. There is also a third, easy-to-miss method: Synset.acyclic_tree(), a vestigial class-attribute alias for acyclic_depth_first — also genuinely recursive and vulnerable.
Important correction to an earlier draft of this finding: Synset.closure(rel, depth=-1) (~line 609) does not share this bug — it actually calls acyclic_breadth_first(), a completely different, iterative queue/deque-based function with no recursion at all. I verified this directly: feeding both acyclic_breadth_first and the real Synset.closure() a 20,000-node genuinely-acyclic chain produces zero crash, while acyclic_depth_first/acyclic_branches_depth_first/Synset.tree()/Synset.acyclic_tree() crash reliably at ~1000-1500 nodes on the identical data. Only .tree() and .acyclic_tree() are affected — not .closure().
This is the same CWE-674 pattern already hardened elsewhere in the codebase (MAX_TREE_DEPTH in tree/tree.py, MAX_DEPTH in featstruct.py, MAX_PARSE_DEPTH in logic.py, MAX_TABLEAU_DEPTH in tableau.py, MAX_DECODE_DEPTH in jsontags.py, added by a commit whose message explicitly enumerates the sinks it covers) — but that hardening pass never reached nltk/util.py or wordnet.py.
Honest scope-limiting fact: I exhaustively measured the maximum possible traversal depth across the entire official, bundled WordNet 3.0 corpus (what the overwhelming majority of real deployments use) for every relation NLTK exposes to tree(): hypernyms/hyponyms max depth = 18 (across all 74,374 noun synsets); also_sees (a relation whose graph isn't curated to stay as shallow as the taxonomy) max eccentricity = 41, largest connected component = 824 nodes; similar_tos max eccentricity = 1; entailments/causes/verb_groups/member_holonyms/member_meronyms/attributes all ≤ 11. Every one of these is roughly 25-60x below the ~1000-node crash threshold — there is no word or relation an attacker could pick against the standard bundled corpus that reaches anywhere near a crash. nltk.app.wordnet_app, NLTK's own bundled reference consumer, only ever calls .tree() with the safe hypernym relation.
Real-world exploitability therefore strictly requires the host application to load a custom/foreign WordNet-format lexical resource — a legitimate, documented, WordNetCorpusReader-supported usage, but a comparatively uncommon one — and then call .tree()/.acyclic_tree() (not .closure()) with the default unbounded depth.
PoC
Generated a syntactically valid, minimal, real Princeton-WordNet-DB-format lexical database (data.noun/index.noun/lexnames/etc., with correct byte-offset-indexed synset records) encoding a 1500-node strictly-linear (genuinely acyclic) hypernym chain. Loaded it via the real, unmodified WordNetCorpusReader(root, None), obtained a real Synset, and called the real, documented, public synset.tree(lambda s: s.hypernyms()) — crashed with an uncaught RecursionError: maximum recursion depth exceeded, as did synset.acyclic_tree(...). synset.closure(...) on the identical data returned cleanly (1499 nodes, no crash), confirming the closure()/tree() distinction above.
Impact
An application that loads a custom WordNet-format lexical resource (e.g. a domain-specific or community-contributed WordNet, which WordNetCorpusReader is explicitly designed to support) and calls .tree()/.acyclic_tree() with an attacker-influenced or simply not-officially-curated relation/resource can be crashed via an unhandled RecursionError from a single long-but-acyclic relation chain. Narrower reach than a bundled-default-corpus bug, but a real, working, unpatched gap in the same CWE-674 family the project actively hardens elsewhere.
Suggested fix: apply the same MAX_TREE_DEPTH-style depth guard to acyclic_depth_first()/acyclic_branches_depth_first() (or reuse the existing Tree constant/pattern directly).
Fix status (2026-09-28)
Status: MERGED on develop (unreleased; v3.10.3 of 2026-08-12 predates the fix).
Fix commit: 0e474a7d7 "Merge commit from fork" (2026-08-26, merged on develop from this advisory's temporary private fork): nltk/util.py gains MAX_RECURSION_DEPTH=500 for the acyclic traversal helpers behind Synset.tree() and acyclic_tree(), with nltk/test/unit/test_wordnet_recursion.py and the probe.
Probe: nltk/test/unit/security_probes/ghsa_8846_p9w9_5frf.py; verdict on develop 2fa3f48fe: FIXED (depth cap prevents recursion overflow).
Release: none yet; no release tag contains 0e474a7d7.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 3.10.3"
},
"package": {
"ecosystem": "PyPI",
"name": "nltk"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.10.4"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-129223"
],
"database_specific": {
"cwe_ids": [
"CWE-674"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-19T23:53:18Z",
"nvd_published_at": "2026-11-19T18:18:07Z",
"severity": "HIGH"
},
"details": "### Summary\nThe recursive traversal engines behind WordNetCorpusReader\u0027s Synset.tree() and Synset.acyclic_tree() have no maximum call-depth safeguard and default to unlimited depth. They guard against literal cycles, but not against a long, genuinely acyclic relation chain \u2014 which exhausts the Python call stack the same way as the sibling DependencyGraph finding I reported separately. Real-world exploitability requires the host application to load a custom/foreign WordNet-format lexical resource rather than NLTK\u0027s bundled default corpus \u2014 flagging that narrower scope honestly up front since it affects severity, not validity.\n\n### Details\n`nltk/util.py`\u0027s `acyclic_depth_first()` (~lines 471-541) and `acyclic_branches_depth_first()` (~lines 544-625) recurse once per graph edge, default to `depth=-1` (\"unlimited\"), and guard against re-visiting the same node via an explicit `traversed` set (hence \"acyclic\") \u2014 but that set only prevents literal cycles, it never bounds how many *distinct* nodes a single call chain may pass through before returning.\n\n`Synset.tree(rel, depth=-1)` (`nltk/corpus/reader/wordnet.py`, ~line 664) calls the recursive `acyclic_branches_depth_first`. There is also a third, easy-to-miss method: `Synset.acyclic_tree()`, a vestigial class-attribute alias for `acyclic_depth_first` \u2014 also genuinely recursive and vulnerable.\n\n**Important correction to an earlier draft of this finding:** `Synset.closure(rel, depth=-1)` (~line 609) does **not** share this bug \u2014 it actually calls `acyclic_breadth_first()`, a completely different, iterative queue/deque-based function with no recursion at all. I verified this directly: feeding both `acyclic_breadth_first` and the real `Synset.closure()` a 20,000-node genuinely-acyclic chain produces zero crash, while `acyclic_depth_first`/`acyclic_branches_depth_first`/`Synset.tree()`/`Synset.acyclic_tree()` crash reliably at ~1000-1500 nodes on the identical data. Only `.tree()` and `.acyclic_tree()` are affected \u2014 not `.closure()`.\n\nThis is the same CWE-674 pattern already hardened elsewhere in the codebase (`MAX_TREE_DEPTH` in `tree/tree.py`, `MAX_DEPTH` in `featstruct.py`, `MAX_PARSE_DEPTH` in `logic.py`, `MAX_TABLEAU_DEPTH` in `tableau.py`, `MAX_DECODE_DEPTH` in `jsontags.py`, added by a commit whose message explicitly enumerates the sinks it covers) \u2014 but that hardening pass never reached `nltk/util.py` or `wordnet.py`.\n\n**Honest scope-limiting fact:** I exhaustively measured the maximum possible traversal depth across the entire official, bundled WordNet 3.0 corpus (what the overwhelming majority of real deployments use) for every relation NLTK exposes to `tree()`: hypernyms/hyponyms max depth = 18 (across all 74,374 noun synsets); `also_sees` (a relation whose graph isn\u0027t curated to stay as shallow as the taxonomy) max eccentricity = 41, largest connected component = 824 nodes; `similar_tos` max eccentricity = 1; entailments/causes/verb_groups/member_holonyms/member_meronyms/attributes all \u2264 11. Every one of these is roughly 25-60x below the ~1000-node crash threshold \u2014 there is no word or relation an attacker could pick against the standard bundled corpus that reaches anywhere near a crash. `nltk.app.wordnet_app`, NLTK\u0027s own bundled reference consumer, only ever calls `.tree()` with the safe hypernym relation.\n\nReal-world exploitability therefore strictly requires the host application to load a custom/foreign WordNet-format lexical resource \u2014 a legitimate, documented, `WordNetCorpusReader`-supported usage, but a comparatively uncommon one \u2014 and then call `.tree()`/`.acyclic_tree()` (not `.closure()`) with the default unbounded depth.\n\n### PoC\nGenerated a syntactically valid, minimal, real Princeton-WordNet-DB-format lexical database (`data.noun`/`index.noun`/`lexnames`/etc., with correct byte-offset-indexed synset records) encoding a 1500-node strictly-linear (genuinely acyclic) hypernym chain. Loaded it via the real, unmodified `WordNetCorpusReader(root, None)`, obtained a real `Synset`, and called the real, documented, public `synset.tree(lambda s: s.hypernyms())` \u2014 crashed with an uncaught `RecursionError: maximum recursion depth exceeded`, as did `synset.acyclic_tree(...)`. `synset.closure(...)` on the identical data returned cleanly (1499 nodes, no crash), confirming the closure()/tree() distinction above.\n\n### Impact\nAn application that loads a custom WordNet-format lexical resource (e.g. a domain-specific or community-contributed WordNet, which `WordNetCorpusReader` is explicitly designed to support) and calls `.tree()`/`.acyclic_tree()` with an attacker-influenced or simply not-officially-curated relation/resource can be crashed via an unhandled `RecursionError` from a single long-but-acyclic relation chain. Narrower reach than a bundled-default-corpus bug, but a real, working, unpatched gap in the same CWE-674 family the project actively hardens elsewhere.\n\nSuggested fix: apply the same `MAX_TREE_DEPTH`-style depth guard to `acyclic_depth_first()`/`acyclic_branches_depth_first()` (or reuse the existing `Tree` constant/pattern directly).\n\n\n## Fix status (2026-09-28)\n\nStatus: MERGED on develop (unreleased; v3.10.3 of 2026-08-12 predates the fix).\n\nFix commit: 0e474a7d7 \"Merge commit from fork\" (2026-08-26, merged on develop from this advisory\u0027s temporary private fork): nltk/util.py gains MAX_RECURSION_DEPTH=500 for the acyclic traversal helpers behind Synset.tree() and acyclic_tree(), with nltk/test/unit/test_wordnet_recursion.py and the probe.\n\nProbe: nltk/test/unit/security_probes/ghsa_8846_p9w9_5frf.py; verdict on develop 2fa3f48fe: FIXED (depth cap prevents recursion overflow).\n\nRelease: none yet; no release tag contains 0e474a7d7.",
"id": "GHSA-8846-p9w9-5frf",
"modified": "2026-11-19T23:53:18Z",
"published": "2026-11-19T23:53:18Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/nltk/nltk/security/advisories/GHSA-8846-p9w9-5frf"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-129223"
},
{
"type": "WEB",
"url": "https://github.com/nltk/nltk/commit/0e474a7d73c95b42aa2c792f364e4f9bf4096c56"
},
{
"type": "PACKAGE",
"url": "https://github.com/nltk/nltk"
},
{
"type": "WEB",
"url": "https://github.com/nltk/nltk/releases/tag/v3.10.4"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in Synset.tree()/acyclic_tree() via WordNet relation traversal"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.