NLTK CCG lexicon parser can be made slow by large inputs

HighSE Fix-First Score 43/100CVE-2026-126299SE-AIV-01440Denial of service and resource exhaustionAI softwareMade public 14 Nov 2026

Download as PDF

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 Score43 of 100
Our own ranking of what to fix first. Real attacks count most, then the chance of attack, then severity.
SecurityElites fix windowWithin 30 days
High severity. This is our suggestion from common practice; your own policy comes first.
Who should own the fixPlatform or application engineering team
Likely effortAbout 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-01440

What 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).

Map where your company uses AI

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

SoftwareAffected versionsMove to
nltk
PyPI
Every version before 3.10.43.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 attackedWorking attack code is public, so expect attacks to follow
Where the attacker must beAnywhere that can reach it over a network, including the internet if it is exposed
Account neededNone. No login is needed
Does a person have to do somethingNo. It works without anyone clicking or opening anything
How hard it is to doEasy. It works reliably once the attacker can reach it
Risk of: data being readNone
Risk of: data or settings being changedNone
Risk of: the service being taken downHigh
Can attackers automate it at scaleYes, according to CISA
How much control an attacker gainsPartial 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_path

Long-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, timestamp

Written 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. Review for past exposureIf you find suspicious activity, review what data might have been accessed and whether the attacker could have caused other damage.
  7. 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.
  8. 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 Version

Pin it in requirements.txtupgrade

nltk>=3.10.4

Check NLTK versionfor this issue

pip show nltk | grep Version

Search 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.

What versions of NLTK are running in our production applications, and which ones need upgrade?A good answer: A good answer lists each application, its NLTK version, and confirms which ones are below 3.10.4.
Which of our services or APIs call nltk.ccg.lexicon.fromstring or accept CCG lexicon input from users?A good answer: A good answer names each service, describes the input source (file upload, API parameter, database, etc.), and confirms whether the input is trusted or untrusted.
If we cannot upgrade immediately, what mitigations can we apply to reduce the risk?A good answer: A good answer includes size limits on lexicon input, request timeouts for parsing, rate limiting, and a plan to upgrade within a specific timeframe.
How would we know if this vulnerability was exploited against us in the past?A good answer: A good answer describes where to check logs (application logs, monitoring dashboards, error tracking), what to look for (slow parsing requests, CPU spikes, timeouts), and what time window to review.

Run a full timed drill with your team

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.

Sign in to track this fix

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-126299

For 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.