NLTK WordNet methods can be made to exhaust the call stack
What this means
An attacker who can make an application load a custom WordNet file can crash it by supplying a long chain of word relations. This causes the service to stop responding until it restarts. This affects applications that accept WordNet data from untrusted sources.
SecurityElites Manager Brief: the decision in one minute
NLTK's WordNet tree-building methods can run out of stack memory if given a long chain of word relations, even if the chain has no cycles. This only happens if your app loads a custom WordNet file from an untrusted source, not NLTK's bundled data. You need to upgrade to NLTK 3.10.4 or later.
| SecurityElites Fix-First Score | 43 of 100 Our own ranking of what to fix first. Real attacks count most, then the chance of attack, then severity. |
|---|---|
| SecurityElites fix window | Within 30 days High severity. This is our suggestion from common practice; your own policy comes first. |
| Who should own the fix | The team that maintains Python application dependencies and deployments. |
| Likely effort | About 30 minutes: check which services use NLTK, upgrade to version 3.10.4 or later, and restart them. It takes longer if you manage many separate deployments or if your NLTK installation is pinned in a complex dependency chain. |
Questions to ask your team or supplier
- Do any of our applications or machine learning pipelines accept or load custom WordNet or lexical data from files, users, or external sources? If so, which ones and how do we validate that data?
- Have we seen any unexplained crashes, stack overflows, or service hangs in NLTK-using services in recent months? If so, could this vulnerability explain them?
Message you can forward to the owning team
Security notice: NLTK WordNet methods can be made to exhaust the call stack (CVE-2026-129223)
Severity: High
SecurityElites Fix-First Score: 43 of 100
SecurityElites fix window: Within 30 days
Action: upgrade to nltk 3.10.4 or later.
What we need from you: confirm whether we run this software, who owns it, and the date it will be fixed.
Full guide: https://securityelites.com/ai-vulnerabilities/cve-2026-129223-nltk-wordnet-methods-can-be-made-to-exhaust-the/
Source: SecurityElites AI Vulnerabilities Database, record SE-AIV-01439What is at stake in your AI setup
- Training or retrieval data: custom WordNet resources used to train or augment language models could be used as an attack vector to crash the pipeline.
- Compute bill: a denial-of-service crash consumes compute resources and blocks legitimate model inference or fine-tuning jobs.
Who is exposed
- Applications that use NLTK and load WordNet data from files outside NLTK's default corpus.
- Services that accept WordNet format files from users or external systems.
- Development or testing setups that experiment with custom lexical resources.
Upgrades you need
| Software | Affected versions | Move to |
|---|---|---|
| nltk PyPI | Every version before 3.10.4 | 3.10.4 or later |
Am I affected?
Enter the version you run. Nothing you type is stored.
SecurityElites Developer Brief: the technical picture
| Is it being attacked | No known attacks and no public attack code when CISA last reviewed it |
|---|---|
| Where the attacker must be | Anywhere that can reach it over a network, including the internet if it is exposed |
| Account needed | None. No login is needed |
| Does a person have to do something | No. It works without anyone clicking or opening anything |
| How hard it is to do | Easy. It works reliably once the attacker can reach it |
| Risk of: data being read | None |
| Risk of: data or settings being changed | None |
| Risk of: the service being taken down | High |
| Can attackers automate it at scale | Yes, according to CISA |
| How much control an attacker gains | Partial control, according to CISA |
Read from the official severity rating: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Kind of coding mistake
- CWE-674
Where it sits in the standards
OWASP Top 10 for LLM Applications 2025: LLM10 Unbounded Consumption
If you cannot upgrade today
- Until you can upgrade, disable or restrict the ability to load custom WordNet data. Remove calls to WordNetCorpusReader with external files, or add a check to reject files that are suspiciously large.
- If custom WordNet loading is essential, limit the depth of tree traversal by modifying your code: before calling .tree() or .acyclic_tree(), validate the data structure or add your own depth limits in wrapper code.
- Run applications in containers or processes with monitored memory and CPU; set a recursion limit or restart policy to minimize impact if a crash occurs.
Signs it may already have been used against you
- Python stack overflow or recursion depth exceeded errors in application logs, especially around WordNet operations or Synset methods.
- Service crashes or restarts with traceback mentioning nltk/corpus/reader/wordnet.py or nltk/util.py.
- Unusual CPU or memory spikes followed by process termination when the application loads or processes WordNet data.
- Error messages containing "acyclic_depth_first", "acyclic_branches_depth_first", "Synset.tree()", or "Synset.acyclic_tree()".
SecurityElites Fix Guide: step by step
- Find where NLTK is installedCheck all Python applications, virtual environments, and containers in your infrastructure. Look for NLTK in requirements.txt, setup.py, pyproject.toml, or pip freeze output. Use your package manager or configuration tool to list all places where NLTK is deployed.
- Check the current NLTK versionOn each system where NLTK is installed, run a command to print the version number. Record all versions you find.
- Review which services load custom WordNet dataSearch your application code for calls to WordNetCorpusReader or for any code that loads .xml files into WordNet structures. Check whether these files come from users, files on disk, network sources, or configuration. Only services that load custom WordNet data from outside NLTK's bundled corpus need to be treated as urgent.
- Upgrade NLTK to 3.10.4 or laterUpdate NLTK to version 3.10.4 or any later version using your package manager. Update your requirements.txt, setup.py, or other dependency files to specify nltk>=3.10.4. Then reinstall the package in all affected environments.
- Restart servicesRestart all Python applications and services that use NLTK so they load the new version. Verify that startup succeeds for each one.
- Verify the fixOn each system, confirm that NLTK version 3.10.4 or later is now installed and running. You can do this by printing the version in a Python shell or checking your deployment logs.
- Check logs for past crashesSearch application error logs and crash reports for the period before this upgrade. Look for Python stack overflow errors, recursion depth exceeded messages, or service crashes that happened when loading WordNet data. If you find any, it may mean an attacker already tried this.
- Restrict custom WordNet loading if possibleIf your application does not need to load custom WordNet files, remove that code or disable the feature. If it does need to load custom files, add validation: check file size limits, restrict file origins to trusted locations, and consider sandboxing the loading process.
How to confirm it is fixed: Confirm that NLTK version 3.10.4 or later is installed in all affected Python environments by running 'python -c "import nltk; print(nltk.__version__)"' and checking the output.
SecurityElites Quick Fixes: copy and paste
Upgrade nltk with pipupgrade
pip install --upgrade "nltk>=3.10.4"
pip show nltk | grep VersionPin it in requirements.txtupgrade
nltk>=3.10.4Check NLTK version in Pythonfor this issue
import nltk
print(nltk.__version__)List installed NLTK version via pipfor this issue
pip show nltk | grep VersionRate and size limits with nginxgeneral hardening
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
server {
location /api/ {
limit_req zone=api burst=20 nodelay;
client_max_body_size 2m;
}
}Test in a non-production environment first. General hardening examples use placeholder names and ports; change them to match your setup.
Let your AI coding assistant do the upgrade
Paste this into the coding assistant you already use, inside the project. It checks first and asks before it changes anything.
Instruction for your coding assistant
You are helping me fix a security vulnerability (CVE-2026-129223) in this project.\n\n1. Search the whole repository, including lock files, container files and CI configuration, for these packages and list every place they are pinned or installed:\n - nltk (PyPI): must be 3.10.4 or later
2. Tell me which version we use now and whether it is affected. Stop and ask me before changing anything.
3. After I agree, raise each one to the safe version, update the lock files, and keep every other dependency as it is.
4. Run the tests and tell me what failed.
5. Give me a short summary of the files you changed that I can put in the pull request.SecurityElites Incident Drill: could your team handle this?
Four questions to ask in your next team meeting. If any has no clear answer, that is the gap to close.
Ticket for your backlog
Paste into Jira, GitHub Issues or any tracker that reads Markdown.
Ready-made ticket
## NLTK WordNet methods can be made to exhaust the call stack (CVE-2026-129223)
**Severity:** High | **SE Fix-First Score:** 43/100 | **Fix window:** Within 30 days
**Record:** SE-AIV-01439 https://securityelites.com/ai-vulnerabilities/cve-2026-129223-nltk-wordnet-methods-can-be-made-to-exhaust-the/
### Why this matters
An attacker who can make an application load a custom WordNet file can crash it by supplying a long chain of word relations. This causes the service to stop responding until it restarts. This affects applications that accept WordNet data from untrusted sources.
### What to do
1. Find where NLTK is installed
2. Check the current NLTK version
3. Review which services load custom WordNet data
4. Upgrade NLTK to 3.10.4 or later
5. Restart services
6. Verify the fix
7. Check logs for past crashes
8. Restrict custom WordNet loading if possible
Full steps: https://securityelites.com/ai-vulnerabilities/cve-2026-129223-nltk-wordnet-methods-can-be-made-to-exhaust-the/
### Done when
- [ ] nltk is at 3.10.4 or later everywhere it is installed
- [ ] Lock files, container images and CI configuration are updated
- [ ] Confirm that NLTK version 3.10.4 or later is installed in all affected Python environments by running 'python -c "import nltk; print(nltk.__version__)"' and checking the output.
- [ ] Logs were checked for signs of earlier use
SecurityElites Fix Tracker
Record who owns this fix, the date it is due and when it is done, and see everything still open in one list. Free with a SecurityElites account.
Related vulnerabilities
In the same software
- NLTK can write files outside its data directory through hardlinks during package extraction High · CVE-2026-128135
- NLTK can run untrusted Java code through command arguments Critical · CVE-2026-128138
- NLTK XML corpus reader CPU exhaustion with large comments or CDATA High · CVE-2026-128139
- NLTK dependency parser crashes on long sentences High · CVE-2026-129222
- NLTK regex patterns can be made to freeze the server High · CVE-2026-129229
- NLTK can run attacker-controlled programs from the current directory High · CVE-2026-129234
The same kind of mistake in other AI tools
- NLTK CCG lexicon parser can be made slow by large inputs High · CVE-2026-126299
- NLTK tree normalizer hangs on wide trees, letting attackers freeze CPU High · CVE-2026-126298
- NLTK CoNLL reader can be made to consume CPU when reading malicious corpus files High · CVE-2026-126297
- NLTK recursive descent parser can be forced to run forever High · CVE-2026-126303
- n8n Git node can freeze the instance with a crafted path High · CVE-2026-86081
Change history
- 19 Nov 2026: Made public
- 1 Dec 2026: Published
- 3 Dec 2026: Guide updated
Official record
### Summary 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 rea
Weakness type: CWE-674
Use this record in your own tools
Get this record as JSON
curl https://securityelites.com/wp-json/se-aivd/v1/vulns/CVE-2026-129223For scanners and pipelines: OSV format · CycloneDX format · API guide · Email alerts · Fix tracker
The plain-language sections were written with AI from the official record, and the upgrade versions come directly from the official data. Last updated 4 Dec 2026. Read the vendor advisory before changing a production system.