NLTK tree normalizer hangs on wide trees, letting attackers freeze CPU
What this means
An attacker who can send tree data to your application can freeze a single CPU core for tens of seconds. This stops that server from handling requests. If your service runs on a small number of cores, the whole service may become unavailable.
SecurityElites Manager Brief: the decision in one minute
NLTK has a performance bug that lets an attacker freeze your server by sending a specially shaped parse tree. Upgrade to NLTK 3.10.4 or later and restart your application.
| 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 | Platform or infrastructure team, with input from app developers who handle tree data. |
| Likely effort | About 15 minutes per service: a pip upgrade, a restart, and a quick test. It could take longer if your app parses trees from many sources and you need to add input checks. |
Questions to ask your team or supplier
- Do we accept parse trees or treebank data from users, files, or APIs that we do not fully control? If so, what size limits do we enforce?
- Have we seen any unexplained CPU spikes or service slowdowns in the past few weeks that could be linked to tree parsing?
- After we upgrade NLTK, can we test that our application still works with the trees we normally process, and that it rejects oversized trees gracefully?
Message you can forward to the owning team
Security notice: NLTK tree normalizer hangs on wide trees, letting attackers freeze CPU (CVE-2026-126298)
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-126298-nltk-tree-normalizer-hangs-on-wide-trees-letting-attackers/
Source: SecurityElites AI Vulnerabilities Database, record SE-AIV-01480What is at stake in your AI setup
- Parse trees and treebanks used for training or fine-tuning NLP models could be corrupted or made unavailable if an attacker fills the queue with freeze attacks.
- Any AI agent or chatbot that parses user input into tree form before normalization could hang and stop responding to users.
- Compute bill: a hang on a wide tree ties up a CPU core, burning compute credits without producing output.
Who is exposed
- Any service that calls Tree.fromstring() or Tree.chomsky_normal_form() on data supplied by users or untrusted sources.
- Web APIs that accept treebank format or parse trees from files or network input.
- Natural language processing pipelines that normalize parse trees without size limits.
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-400: resources can be exhausted
- CWE-407
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, do not call chomsky_normal_form() on trees loaded from untrusted sources; use the left-factor variant if you must: t.chomsky_normal_form(factor='left') instead of the default.
- Add a check to reject any tree where a single node has more than 100 children before calling any transform on it.
- If possible, run tree normalization in a worker process with a timeout so a hang does not block your main service.
Signs it may already have been used against you
- Check application logs for requests that cause the service to become slow or unresponsive.
- Look for single-threaded CPU usage spiking to 100% while other cores stay idle, especially after tree parsing operations.
- Review access logs for requests that submit very large tree structures or deeply nested brackets, especially if they correlate with performance drops.
- Monitor for repeated failed requests or timeouts from the same source, which may indicate an attacker testing tree sizes.
Log searches to start from
Single-threaded CPU spike during tree operations (field names must be adapted to your logs)Splunk
index=main ("chomsky_normal_form" OR "fromstring") | stats avg(cpu_usage) by host, process_name | where cpu_usage > 90 AND core_count=1Requests with large bracket-nested input (field names must be adapted)Elastic
process.name:python AND (message:"Tree.fromstring" OR message:"chomsky_normal_form") | stats count() by source.ip | where count > 10Written with AI as a starting point. Review them and change the index and field names to match your own logs before you rely on the result.
SecurityElites Fix Guide: step by step
- Find where NLTK is installedCheck your requirements.txt, setup.py, pyproject.toml or Pipfile for nltk. Run pip show nltk to see the current version.
- Check the current versionRun pip show nltk and note the version number. If it is 3.10.4 or later, the fix is already in place.
- Upgrade NLTK to 3.10.4 or laterRun pip install --upgrade nltk==3.10.4 or use your package manager to bring NLTK to version 3.10.4 or any later version.
- Restart your applicationStop and start your service, container, or process so it loads the new NLTK code.
- Verify the upgradeRun pip show nltk again and confirm the version is 3.10.4 or higher.
- Review tree input sourcesList all places in your code where Tree.fromstring() is called or tree data is accepted from outside your application. Note whether the input is trusted.
- Check logs for suspicious activity before the upgradeLook at application logs and CPU usage graphs from the past week for unusual spikes or slowdowns that happened when processing tree data. If you see sustained high CPU on one core around the time an attacker might have submitted input, escalate to your security team.
- Add size limits if trees come from untrusted sourcesIf your app accepts tree input from users or the internet, add a check to reject trees with nodes that have more than a reasonable number of children (for example, more than 100). This reduces risk even if a future bug is found.
How to confirm it is fixed: Run pip show nltk and confirm the version is 3.10.4 or higher, then restart your application and test that it still processes your normal tree inputs without hanging.
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 from command linefor this issue
pip show nltk | grep VersionCheck NLTK version from Pythonfor this issue
import nltk
print(nltk.__version__)Example tree size check before normalization (optional hardening)for this issue
from nltk.tree import Tree
def safe_normalize(tree_string, max_children=100):
t = Tree.fromstring(tree_string)
for subtree in t.subtrees():
if len(subtree) > max_children:
raise ValueError(f"Tree node has {len(subtree)} children, limit is {max_children}")
return t.chomsky_normal_form()Rate 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-126298) 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 tree normalizer hangs on wide trees, letting attackers freeze CPU (CVE-2026-126298)
**Severity:** High | **SE Fix-First Score:** 43/100 | **Fix window:** Within 30 days
**Record:** SE-AIV-01480 https://securityelites.com/ai-vulnerabilities/cve-2026-126298-nltk-tree-normalizer-hangs-on-wide-trees-letting-attackers/
### Why this matters
An attacker who can send tree data to your application can freeze a single CPU core for tens of seconds. This stops that server from handling requests. If your service runs on a small number of cores, the whole service may become unavailable.
### What to do
1. Find where NLTK is installed
2. Check the current version
3. Upgrade NLTK to 3.10.4 or later
4. Restart your application
5. Verify the upgrade
6. Review tree input sources
7. Check logs for suspicious activity before the upgrade
8. Add size limits if trees come from untrusted sources
Full steps: https://securityelites.com/ai-vulnerabilities/cve-2026-126298-nltk-tree-normalizer-hangs-on-wide-trees-letting-attackers/
### Done when
- [ ] nltk is at 3.10.4 or later everywhere it is installed
- [ ] Lock files, container images and CI configuration are updated
- [ ] Run pip show nltk and confirm the version is 3.10.4 or higher, then restart your application and test that it still processes your normal tree inputs without hanging.
- [ ] 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 WordNet methods can be made to exhaust the call stack High · CVE-2026-129223
- NLTK regex patterns can be made to freeze the server High · CVE-2026-129229
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 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
- n8n Edit Fields node can crash the whole instance with a bad field name High · CVE-2026-72749
Change history
- 14 Nov 2026: Made public
- 1 Dec 2026: Published
- 3 Dec 2026: Guide updated
Official record
## Summary`Tree.chomsky_normal_form()` binarizes a parse tree and defaults to right factoring. For a node with N children the right-factor branch repeatedly removes the first element of a working list with `list.pop(0)`, which shifts all remaining elements each time, so binarizing one wide node costs O(N^2). An application that converts an attacker-supplied treebank tree to Chomsky Normal Form can be forced into tens of seconds of single-threaded CPU by one wide flat tree. No authentication or user interaction is required.## Root CauseIn the default right-factor branch the transform executes `curNode[0:] = [nodeCopy.pop(0), newNode]` inside a loop over the N children of a node. `list.pop(0)` is O(len) because it shifts every remaining element down by one; performed N-2 times over a shrinking length-N list this sums to O(N^2). The left-factor branch instead uses `nodeCopy.pop()` (removing the last element), which is O(1) and linear overall, so the two branches differ only by this front-versus-back removal. No cap is placed on the child count of a node, and the public `Tree.fromstring` parser accepts an arbitrarily wide bracketed tree.```text Affected function: - nltk.tree.transforms.chomsky_normal_form (nltk/tree/transforms.py; right-factor sink at line 168, O(1) left control at line 179) Public entry points: nltk.tree.Tree.chomsky_normal_form (nltk/tree/tree.py:455, default factor="right"); nltk.tree.Tree.fromstring (nltk/tree/tree.py:592). ```## ImpactAn attacker who can influence the tree that an application normalizes to Chomsky Normal Form causes sustained single-threaded CPU consumption (availability loss). The path is network-reachable (AV:N) and needs no privileges or user interaction (PR:N, UI:N). Because the cost grows quadratically with the attacker-chosen child count, roughly 1.5 MB of treebank input costs about 14 seconds on one core and scales as N^2 above that. Confidentiality and integrity are not affected. The NLTK regular-expression wall-clock timeout wraps regex matching only and does not wrap this pure-Python list loop.## Proof of Concept```text Environment: nltk 3.10.3, CPython. Drive the public transform on a wide flat tree. ``````python import time from nltk.tree import Treefor N in (80000, 160000, 320000): s = "(S " + "(A a)" * N + ")" t = Tree.fromstring(s) start = time.perf_counter() t.chomsky_normal_form() # default factor="right" print("right", N, round(time.perf_counter() - start, 3), "s") ``````text right (default): N=80000 1.972s | N=160000 5.004s (2.54x) | N=320000 14.518s (2.90x) -> super-linear left (control): N=80000 1.399s | N=160000 2.731s (1.95x) | N=320000 5.379s (1.97x) -> linear ```## Attack Chain1. **Exposure:** An application parses an attacker-influenced treebank string with the public `Tree.fromstring` and normalizes it with `Tree.chomsky_normal_form()`. 2. **Control:** The attacker controls the number of children of a node (a wide flat tree such as `(S (A a)(A a)...(A a))`); no child-count cap exists in `fromstring` or the transform. 3. **Path:** `Tree.chomsky_normal_form` delegates to `nltk.tree.transforms.chomsky_normal_form` with the default `factor="right"`. 4. **Guard:** None. There is no width bound on the loop, and the regex match timeout does not wrap this pure-Python list operation. 5. **Primitive:** `curNode[0:] = [nodeCopy.pop(0), newNode]` performs an O(N) front shift on each of N iterations. 6. **Result:** O(N^2) single-core CPU exhaustion; roughly 1.5 MB of input costs about 14 seconds and scales quadratically, blocking the processing thread.## Bypass EvidenceThere is no guard to bypass on this path: neither `Tree.fromstring` nor `chomsky_normal_form` caps the child count, and the regular-expression wall-clock timeout wraps only regex matching, not this list loop. The finding was confirmed by fresh timing that isolates the cause: the right-factor default and the left-factor branch build the identical bo
Weakness type: CWE-400, CWE-407
Use this record in your own tools
Get this record as JSON
curl https://securityelites.com/wp-json/se-aivd/v1/vulns/CVE-2026-126298For 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.