NLTK CCG lexicon parser can be made slow by large inputs
What this means
An attacker can send a specially crafted text input to an application that parses CCG lexicons, causing the parser to consume CPU for tens of seconds. This can freeze request workers, make the service unresponsive, and disrupt legitimate users. A few megabytes of input is enough to cause this damage.
SecurityElites Manager Brief: the decision in one minute
The NLTK library's CCG lexicon parser is vulnerable to denial of service when it processes large inputs. An attacker can send a few megabytes of crafted text to freeze the service for tens of seconds. You need to upgrade NLTK to version 3.10.4 immediately if your application accepts CCG lexicon text from users or the network.
| 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 application engineering team |
| Likely effort | About 15 minutes per application: check the version of NLTK, upgrade to 3.10.4, test that the application starts, and restart. Time could be longer if you have many services or if you need to test with real data. |
Questions to ask your team or supplier
- Does your application accept CCG lexicon text from users, uploaded files, or external APIs? If yes, upgrading is urgent.
- Do you have request timeouts or rate limits on CCG lexicon parsing today? If not, add them in addition to upgrading.
- Have you seen any unexplained CPU spikes, timeouts, or slow requests in the past month that might indicate this was exploited?
Message you can forward to the owning team
Security notice: NLTK CCG lexicon parser can be made slow by large inputs (CVE-2026-126299)
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-126299-nltk-ccg-lexicon-parser-can-be-made-slow-by/
Source: SecurityElites AI Vulnerabilities Database, record SE-AIV-01440What is at stake in your AI setup
- Tools and systems the agent is connected to: a compromised CCG parser could allow an attacker to control or disrupt downstream NLP processing or model inference.
- The compute bill: denial-of-service attacks that drive CPU usage high will increase cloud costs or waste reserved capacity.
- Training or retrieval data: if CCG lexicons are built from sensitive training data, a slowdown attack could expose patterns in which lexicons are large (information leakage).
Who is exposed
- Applications that call nltk.ccg.lexicon.fromstring or nltk.ccg.chart.fromstring with untrusted input (from users, files, APIs, or the network).
- Services that expose CCG lexicon parsing to users or external systems without rate limits.
- Teams running NLTK versions before 3.10.4.
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 | Working attack code is public, so expect attacks to follow |
|---|---|
| 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
- Before upgrading, add a strict size limit to any CCG lexicon text accepted from users or the network. Reject inputs larger than 10 KB (or a size you have tested to be safe).
- Add a timeout to CCG lexicon parsing operations. If parsing takes more than 5 seconds, kill the operation and return an error.
- Temporarily disable any user-facing feature that accepts CCG lexicon input until you can upgrade NLTK.
Signs it may already have been used against you
- High CPU usage on a single thread or process without an obvious reason (parser hanging or running for many seconds).
- Request timeouts or slow responses when CCG lexicon parsing is called, especially after a request with a large text input.
- Error logs mentioning `nltk.ccg.lexicon` or `fromstring` with large inputs or unusual input patterns (very long lines with many repeated characters).
- Monitoring alerts for elevated CPU time per request on the application or worker that handles CCG parsing.
Log searches to start from
High CPU time for NLTK CCG parsing (adapt field names to your logs)Splunk
process=nltk OR process=ccg cpu_time > 10 | stats avg(cpu_time) by source, request_pathLong-running requests with CCG lexicon parsing (adapt field names to your logs)Elastic
message:"ccg" AND message:"lexicon" AND duration_ms > 5000 | stats count by source_ip, timestampWritten 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 installedList all Python environments or containers that run your application. For each one, run `pip show nltk` or check your requirements.txt, setup.py, or pyproject.toml to find the installed version.
- Check if CCG lexicon parsing is usedSearch your codebase for calls to `nltk.ccg.lexicon.fromstring`, `nltk.ccg.chart.fromstring`, or any import of these functions. If found, the application is at risk if the input comes from users or untrusted sources.
- Review input sourcesFor each place where CCG lexicon parsing happens, check whether the input can be influenced by an attacker: uploaded files, API parameters, configuration fetched from the network, or data from other users. If yes, the risk is high.
- Upgrade NLTK to version 3.10.4In your Python environment, run `pip install --upgrade nltk==3.10.4` or update your dependency file to require `nltk>=3.10.4` and reinstall. If you use containers or virtual environments, upgrade in each one.
- Verify the upgrade workedRun `pip show nltk` and confirm the version is 3.10.4 or higher. Restart the application or service to load the new code.
- Review for past exposureIf you find suspicious activity, review what data might have been accessed and whether the attacker could have caused other damage.
- Add input size limitsIf CCG lexicon parsing accepts untrusted input, add a size limit before parsing. For example, reject any lexicon text larger than a reasonable threshold (such as 100 KB) and log the rejection. This reduces the risk even if a future bug is found.
- Add request timeoutsSet a CPU or wall-clock timeout for CCG lexicon parsing operations. If parsing takes longer than a few seconds, cancel it and return an error. This prevents one malicious request from freezing a worker thread.
How to confirm it is fixed: Confirm that NLTK version 3.10.4 or higher is installed by running `pip show nltk`, and test that the application starts and responds normally to requests.
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 versionfor this issue
pip show nltk | grep VersionSearch for CCG lexicon usage in Python codefor this issue
grep -r "nltk.ccg" . --include="*.py" | grep -E "(lexicon\.fromstring|chart\.fromstring)"Example: add input size limit before parsingfor this issue
import nltk.ccg.lexicon as L
MAX_LEXICON_SIZE = 100000 # 100 KB
if len(lex_text) > MAX_LEXICON_SIZE:
raise ValueError(f"Lexicon text exceeds {MAX_LEXICON_SIZE} bytes")
lexicon = L.fromstring(lex_text)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-126299) 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 CCG lexicon parser can be made slow by large inputs (CVE-2026-126299)
**Severity:** High | **SE Fix-First Score:** 43/100 | **Fix window:** Within 30 days
**Record:** SE-AIV-01440 https://securityelites.com/ai-vulnerabilities/cve-2026-126299-nltk-ccg-lexicon-parser-can-be-made-slow-by/
### Why this matters
An attacker can send a specially crafted text input to an application that parses CCG lexicons, causing the parser to consume CPU for tens of seconds. This can freeze request workers, make the service unresponsive, and disrupt legitimate users. A few megabytes of input is enough to cause this damage.
### What to do
1. Find where NLTK is installed
2. Check if CCG lexicon parsing is used
3. Review input sources
4. Upgrade NLTK to version 3.10.4
5. Verify the upgrade worked
6. Review for past exposure
7. Add input size limits
8. Add request timeouts
Full steps: https://securityelites.com/ai-vulnerabilities/cve-2026-126299-nltk-ccg-lexicon-parser-can-be-made-slow-by/
### 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 higher is installed by running `pip show nltk`, and test that the application starts and responds normally to requests.
- [ ] 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 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
- 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
## SummaryThe public CCG lexicon parser `nltk.ccg.lexicon.fromstring` parses caller-influenced lexicon text with two pure-Python loops whose cost is quadratic in the input width. A service that parses an untrusted CCG lexicon string can be driven into tens of seconds of single-threaded CPU by a few-megabyte input, starving the request worker. No authentication or user interaction is required.## Root Cause`matchBrackets` consumes a bracket body one character at a time with `inside = inside + rest[0]; rest = rest[1:]`. The `rest = rest[1:]` tail re-slice copies the entire remaining string on every iteration, so a flat bracket body costs O(n^2). `augParseCategory` drives a `while rest != "":` operator loop that re-copies the regular-expression match tail (`rest = app[3]`) once per operator, which is also O(n^2) over a long operator chain. The parser carries a recursion-depth guard (`MAX_PARSE_DEPTH = 500`) that raises on deeply nested categories, but both quadratic loops run on flat input whose nesting depth stays at zero, so that guard never fires. No bound is applied to line length or category width before the text reaches these loops.```text Affected functions: - nltk.ccg.lexicon.matchBrackets (nltk/ccg/lexicon.py:149-172; tail re-slice at line 168) - nltk.ccg.lexicon.augParseCategory (nltk/ccg/lexicon.py:223-268; APP_RE tail re-copy at line 250) Public entry point: nltk.ccg.lexicon.fromstring (nltk/ccg/lexicon.py:271), also re-exported as nltk.ccg.chart.fromstring. ```## ImpactAn attacker who can influence the CCG lexicon string parsed by an application causes sustained single-threaded CPU consumption (availability loss). The vulnerable path is network-reachable (AV:N) and needs no privileges or user interaction (PR:N, UI:N). Because the cost grows quadratically with attacker-chosen input size, a few-megabyte payload costs tens of seconds per core, and a small number of concurrent requests can exhaust worker threads. Confidentiality and integrity are not affected. The NLTK regular-expression wall-clock timeout wraps regex matching only; it does not wrap these pure-Python slicing loops, so it provides no protection here.## Proof of Concept```text Environment: nltk 3.10.3, regex 2026.9.10, CPython. Run the parser on the shipped public API. ``````python import nltk.ccg.lexicon as L# Vector A: flat bracket body -> matchBrackets tail re-slice is O(n^2) n = 400000 lex_a = ":- S\nw => (" + "a" * n + ")\n"# Vector B: long operator chain -> augParseCategory tail re-copy is O(n^2) m = 32000 lex_b = ":- a\nw => " + "a" + "/a" * m + "\n"import time for name, s in (("A", lex_a), ("B", lex_b)): t = time.perf_counter() try: L.fromstring(s) except Exception: pass # downstream parse error is irrelevant; the CPU is already burned print(name, round(time.perf_counter() - t, 3), "s") ``````text Negative control (":- a\nw => (a/a)"): ~0.00007 s Vector A (matchBrackets, flat body): n=50k 0.078s | 100k 0.260s | 200k 1.046s | 400k 2.083s (~4x per doubling => O(n^2)) Vector B (augParseCategory, operators): m=4k 0.078s | 8k 0.215s | 16k 0.485s | 32k 1.329s (super-linear) ```## Attack Chain1. **Exposure:** An application calls the public `nltk.ccg.lexicon.fromstring(lex_str)` (also reachable as `nltk.ccg.chart.fromstring`) on lexicon text the attacker can influence. 2. **Control:** The attacker fully controls the body width (a run of characters inside one bracket) and the operator-chain length; neither is capped by `fromstring`. 3. **Path:** `fromstring` splits input into lines and routes each category through `nextCategory`, which dispatches to `matchBrackets` (Vector A) or into the `augParseCategory` operator loop (Vector B). 4. **Guard:** The only relevant guard is the `MAX_PARSE_DEPTH = 500` recursion-depth check. On flat input the recursion depth is zero, so `if _depth > max_depth` is never reached; the width loops run unbounded. 5. **Primitive:** The tail re-sl
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-126299For 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.