{"vuln_id":"GHSA-8846-p9w9-5frf","aliases":["CVE-2026-129223"],"description":"Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in Synset.tree()/acyclic_tree() via WordNet relation traversal","published_at":"2026-11-19T23:53:18Z","modified_at":"2026-11-20T00:00:05.085128Z","first_seen_at":"2026-11-21T19:15:19.352564Z","severity":"high","severity_source":"ghsa","cvss_score":7.5,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","cwe":["CWE-674"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-8846-p9w9-5frf"},"matched_alias":null,"items":[{"id":10694,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-8846-p9w9-5frf: Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in Synset.tree()/acyclic_tree() via WordNet relation traversal","summary":"Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in Synset.tree()/acyclic_tree() via WordNet relation traversal\n\n### Summary\nThe 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.\n\n### Details\n`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.\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` — 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 — 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()`.\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) — 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'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. Ev\n\nAffected: PyPI:nltk\n\nFixed in: 3.10.4\n\nReferences:\nhttps://github.com/nltk/nltk/security/advisories/GHSA-8846-p9w9-5frf\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-129223\nhttps://github.com/nltk/nltk/commit/0e474a7d73c95b42aa2c792f364e4f9bf4096c56\nhttps://github.com/nltk/nltk\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4","url":"https://osv.dev/vulnerability/GHSA-8846-p9w9-5frf","published_at":"2026-11-19T23:53:18Z","updated_at":"2026-11-20T00:00:05.085128Z","fetched_at":"2026-11-21T19:15:55.946109Z","severity":"high","cvss_score":7.5,"epss":0.0051,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-129223","vuln_ids":["CVE-2026-129223","GHSA-8846-P9W9-5FRF"],"tags":["osv","pypi","fix-available"],"cluster_id":2143,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10694","html":"https://vulnwatch.ve1ve2.com/item/10694"}},{"id":2356,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-8846-p9w9-5frf / CVE-2026-129223: Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in Synset.tree()/acyclic_tree() via WordNet relation traversal","summary":"Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in Synset.tree()/acyclic_tree() via WordNet relation traversal\n\n### Summary\nThe 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.\n\n### Details\n`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.\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` — 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 — 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()`.\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) — 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'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. Ev\n\nAffected packages: pip:nltk\nPatched: nltk 3.10.4","url":"https://github.com/advisories/GHSA-8846-p9w9-5frf","published_at":"2026-11-19T23:53:18Z","updated_at":"2026-11-19T23:53:19Z","fetched_at":"2026-11-21T19:15:18.416774Z","severity":"high","cvss_score":7.5,"epss":0.0051,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-129223","vuln_ids":["CVE-2026-129223","GHSA-8846-P9W9-5FRF"],"tags":["ghsa","pip","CWE-674"],"cluster_id":2143,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2356","html":"https://vulnwatch.ve1ve2.com/item/2356"}},{"id":9036,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-129223: NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Proc…","summary":"NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. Prior to 3.10.4, WordNet Synset.tree and acyclic_tree traverse relation graphs through recursive utility helpers without a depth bound. Exploitation requires the host application to load an attacker-influenced custom or foreign WordNet-format lexical resource; no relation in NLTK's bundled WordNet 3.0 corpus reaches the crash threshold. An excessively deep relation graph in such a resource can exceed the Python recursion limit and terminate the traversal or request worker. This issue is fixed in version 3.10.4.\n\nReferences:\nhttps://github.com/nltk/nltk/commit/0e474a7d73c95b42aa2c792f364e4f9bf4096c56\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4\nhttps://github.com/nltk/nltk/security/advisories/GHSA-8846-p9w9-5frf","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129223","published_at":"2026-11-19T18:18:07.320000Z","updated_at":"2026-11-20T22:17:49.057000Z","fetched_at":"2026-11-21T19:15:31.484689Z","severity":"high","cvss_score":7.5,"epss":0.0051,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-129223","vuln_ids":["CVE-2026-129223","GHSA-8846-P9W9-5FRF"],"tags":["CWE-674"],"cluster_id":2144,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/9036","html":"https://vulnwatch.ve1ve2.com/item/9036"}}]}