NLTK regex compilation denial of service via many groups

HighSE Fix-First Score 43/100CVE-2026-129229SE-AIV-01419Missing or broken access controlAI softwareMade public 20 Nov 2026

Download as PDF

What this means

An attacker can send a small request with a specially crafted search pattern that forces NLTK to spend tens of seconds compiling a regular expression, pinning one CPU core. Multiple requests can exhaust all cores and make the application stop responding. Services that accept user input for text search or tokenization are at risk.

SecurityElites Manager Brief: the decision in one minute

NLTK versions 3.10.0–3.10.3 can be forced to freeze for tens of seconds while compiling a carefully crafted search pattern. An attacker can crash your service with a small request. Upgrade to NLTK 3.10.4 immediately if you use text search or tokenization with user-supplied patterns.

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 team that runs NLTK-based services.
Likely effortAbout 15 minutes per service: update NLTK to version 3.10.4 and restart. Longer if you have pinned dependencies or multiple environments to test.

Questions to ask your team or supplier

  • Which of your applications use NLTK for text search or tokenization, and do any of them accept regex patterns or search terms from users or external sources?
  • Do you have automated testing and deployment for NLTK updates, or is each service updated manually? Can you upgrade all affected instances within a day?
  • If an attacker sent 100 specially crafted search requests at once, how would you detect it, and what would happen to your service?

Message you can forward to the owning team

Security notice: NLTK regex compilation denial of service via many groups (CVE-2026-129229)

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-129229-nltk-regex-compilation-denial-of-service-via-many-groups/
Source: SecurityElites AI Vulnerabilities Database, record SE-AIV-01419

What is at stake in your AI setup

  • Keys for external AI APIs: if the service uses NLTK to preprocess prompts or query results for an AI model, an attacker can delay or block those requests, disrupting the AI workflow.
  • Tools and systems an agent is connected to: if an AI agent uses NLTK to parse or filter tool output, a denial-of-service here could prevent the agent from accessing those tools.
  • Compute bill: forced CPU consumption increases cloud costs and can trigger auto-scaling, raising your bill until the attack stops.

Map where your company uses AI

Who is exposed

  • Teams running NLTK 3.10.0 through 3.10.3 with any user-supplied text search or tokenization.
  • Services that accept regex patterns from end users or untrusted sources.
  • APIs or batch jobs that call TokenSearcher.findall(), Text.findall(), or RegexpTokenizer with external input.
  • Not affected: NLTK versions before 3.10.0, or 3.10.4 and later.

Upgrades you need

SoftwareAffected versionsMove to
nltk
PyPI
3.10.0 up to, but not including, 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-1333: a slow pattern match can freeze the service
  • CWE-400: resources can be exhausted

If you cannot upgrade today

  • If you cannot upgrade immediately, disable user-supplied regex patterns. Restrict search and tokenization to a whitelist of safe, pre-compiled patterns.
  • Add a timeout or resource limit at the application level before NLTK is called (e.g., fail fast if the pattern looks suspicious: contains >100 groups, is >10KB, or has deep nesting).
  • If the service is an API, add rate limiting and request size limits to slow down attackers.

Signs it may already have been used against you

  • CPU usage: look for sustained 100% CPU on a single core that coincides with application requests.
  • Request logs: search for very long or unusual regex patterns with many parentheses (e.g., patterns containing repeated `()`), or requests that timeout during text-search operations.
  • Application logs: check for slow or hanging calls to TokenSearcher.findall(), Text.findall(), or RegexpTokenizer initialization.
  • Response times: look for sudden spikes in latency or hanging requests at the moment CPU jumps to 100%.

Log searches to start from

Single-core CPU spikes around NLTK calls (adapt field names to your logs)Splunk

index=main source=*/cpu.log core=0 value>95 | search _time=* | join type=left _time [search index=main source=*/app.log "TokenSearcher\|findall\|RegexpTokenizer"]

Long-running regex compilation or matching (adapt field names)Elastic

process.name:python AND message:(TokenSearcher OR RegexpTokenizer) AND duration_ms>5000

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 servers, containers and environments running your application. Check which ones have NLTK 3.10.0, 3.10.1, 3.10.2, or 3.10.3 installed. Use pip list or your package manager to confirm the version.
  2. Check if your code uses vulnerable functionsSearch your codebase for calls to TokenSearcher.findall(), Text.findall(), or RegexpTokenizer. If these functions exist and receive input from users, the web, files, or databases, they are at risk. If you do not use these functions, the risk is lower but you should still upgrade.
  3. Review access controls on pattern inputCheck whether your application accepts regex patterns, search terms, or tokenizer rules from untrusted sources (users, APIs, files). If yes, document which services and which entry points are exposed.
  4. Back up your current configurationSave a copy of your requirements.txt, Pipfile, setup.py or other dependency file. Take a snapshot of the current environment so you can roll back if needed.
  5. Upgrade NLTK to 3.10.4Update your NLTK package to version 3.10.4 using your package manager. For pip, run pip install --upgrade nltk==3.10.4. For other tools, use the equivalent upgrade command.
  6. Test the fixRun your application's test suite, especially tests that exercise text search and tokenization. Restart the service and verify it starts cleanly. Confirm that normal search and tokenization still work.
  7. Check for signs of prior attackLook at your CPU and request logs for the time before the upgrade. Search for sustained high CPU use, slow responses, or timeouts around text-search operations. Check for unusual or very long regex patterns in logs.
  8. Document the fix and roll-out planRecord which services were upgraded, when, and what version they are running. If you have multiple environments (dev, staging, production), upgrade each one and log the completion.

How to confirm it is fixed: Run a test that calls TokenSearcher.findall() or RegexpTokenizer with a normal pattern and confirm it completes in under 1 second; then confirm that your NLTK version is 3.10.4 or later and the application starts without errors.

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 version on a machinefor this issue

python -c "import nltk; print(nltk.__version__)"

Search Python code for vulnerable function callsfor this issue

grep -r "TokenSearcher\|Text\.findall\|RegexpTokenizer" --include="*.py" .

Require sign-in with nginx in front of the servicegeneral hardening

location / {
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd;
    proxy_pass http://127.0.0.1:8080;
}

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-129229) 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 is the vulnerable function in NLTK that an attacker would target?A good answer: TokenSearcher.findall(), Text.findall(), or RegexpTokenizer, when they receive untrusted regex patterns that can have many groups or complex nesting.
Why does the timeout in NLTK not stop this attack?A good answer: The timeout guards only the matching phase, not the compilation phase; the attacker's pattern is expensive to compile, so the CPU is pinned before matching even begins.
What would you see if your service was under attack?A good answer: One or more CPU cores stuck at 100%, application requests hanging or timing out, and possibly very long or unusual regex patterns in request logs.
What is the fix?A good answer: Upgrade NLTK to version 3.10.4, which bounds the number of groups and other regex properties before compilation.

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 regex compilation denial of service via many groups (CVE-2026-129229)

**Severity:** High  |  **SE Fix-First Score:** 43/100  |  **Fix window:** Within 30 days
**Record:** SE-AIV-01419 https://securityelites.com/ai-vulnerabilities/cve-2026-129229-nltk-regex-compilation-denial-of-service-via-many-groups/

### Why this matters
An attacker can send a small request with a specially crafted search pattern that forces NLTK to spend tens of seconds compiling a regular expression, pinning one CPU core. Multiple requests can exhaust all cores and make the application stop responding. Services that accept user input for text search or tokenization are at risk.

### What to do
1. Find where NLTK is installed
2. Check if your code uses vulnerable functions
3. Review access controls on pattern input
4. Back up your current configuration
5. Upgrade NLTK to 3.10.4
6. Test the fix
7. Check for signs of prior attack
8. Document the fix and roll-out plan

Full steps: https://securityelites.com/ai-vulnerabilities/cve-2026-129229-nltk-regex-compilation-denial-of-service-via-many-groups/

### Done when
- [ ] nltk is at 3.10.4 or later everywhere it is installed
- [ ] Lock files, container images and CI configuration are updated
- [ ] Run a test that calls TokenSearcher.findall() or RegexpTokenizer with a normal pattern and confirm it completes in under 1 second; then confirm that your NLTK version is 3.10.4 or later and the application starts without errors.
- [ ] 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

  • 19 Nov 2026: Made public
  • 1 Dec 2026: Published

Official record

## SummaryNLTK exposes a compile-time regular-expression denial of service in its regex-search helpers. When an application passes untrusted text as the search pattern to `TokenSearcher.findall()` / `Text.findall()`, or as the tokenizer pattern to `RegexpTokenizer`, the pattern is handed to the third-party `regex` engine, whose compilation cost is roughly quadratic in the number of capturing groups. A short pattern of the form `()` repeated many times (for example `"()" * 25000`, about 50 KB) forces tens of seconds of synchronous CPU work before any match begins. The wall-clock timeout that NLTK added to guard matching does not apply during compilation, so a single small request pins a CPU core, and repeated or concurrent requests exhaust all cores and deny service.## Root CauseThe remediation for the earlier match-time backtracking issue (advisory GHSA-rrv8-h7p8-rx55 / CVE-2026-80205) switched the caller-supplied-pattern search path from the standard library `re` module to the third-party `regex` engine and wrapped matching in a wall-clock timeout. That timeout is a match-time limit only: it is applied while the compiled pattern scans the corpus. Compilation of the pattern happens first and synchronously, outside any timeout. The `regex` engine's compiler is approximately O(n^2) in the number of regex groups, so a caller-controlled pattern consisting of many empty groups makes compilation, not matching, the expensive step. No control bounds the group count of a caller-supplied pattern before compilation.```text Affected components / functions: - nltk.text.TokenSearcher.findall (nltk/text.py) -> regex.findall(pattern, corpus, timeout=...) On released 3.10.0-3.10.2 this sink calls regex.findall directly; on 3.10.3 and later it routes through nltk.redos.compile. Either way the regex engine compiles the caller pattern with no group-count bound, and the timeout guards only matching. - nltk.redos.compile (nltk/redos.py, introduced in 3.10.3) -> regex.compile(src, flags) Called synchronously before the timeout-bearing wrapper exists. On released 3.10.3 there is no pre-compile guard at all; on the current development tree a check_pattern bounds source length, nesting depth, and counted-repeat product, but not the number of groups. ```## ImpactAn unauthenticated attacker who can influence a regular-expression string that reaches one of these NLTK search or tokenizer entry points can force amplified CPU consumption. A single request carrying an approximately 50 KB pattern of empty groups blocks a worker for tens of seconds; because cost grows quadratically with group count, a larger pattern (unbounded on the released 3.10.3 artifact, which imposes no length cap) or a modest number of concurrent requests exhausts every available core and denies service to legitimate users. There is no confidentiality or integrity impact, and service recovers once compilation finishes or the worker is terminated. This is the same class of unauthenticated denial of service as the prior match-time ReDoS, but reached through the compilation path that the prior fix does not cover.## Proof of Concept`Requires the nltk package (3.10.0 through 3.10.3) and its declared regex dependency. No corpus data or network access is needed.`1. Build a pattern of many empty capturing groups. 2. Pass it to any caller-supplied-pattern sink; measure the time spent before matching. 3. Observe that the match timeout does not fire, because the cost is in compilation.```python import time, regex# Exact released 3.10.0-3.10.2 code path of TokenSearcher.findall: # regex.findall(pattern, corpus, timeout=<wall-clock match limit>) pattern = "()" * 25000 # ~50 KB, 25000 capturing groups; survives the "<>." rewrites start = time.perf_counter() try: regex.findall(pattern, "<hello><world><foo>", timeout=1.0) print(f"completed in {time.perf_counter()-start:.2f}s with NO TimeoutError") except TimeoutError: print(f"Tim

Weakness type: CWE-1333, CWE-400

Use this record in your own tools

Get this record as JSON

curl https://securityelites.com/wp-json/se-aivd/v1/vulns/CVE-2026-129229

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 1 Dec 2026. Read the vendor advisory before changing a production system.