NLTK regex patterns can be made to freeze the server

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 who can send text to be searched or tokenized can freeze a server for tens of seconds by forcing expensive regex compilation. This stops the application from responding to other users, and repeated attacks exhaust all CPU cores and crash the service.

SecurityElites Manager Brief: the decision in one minute

NLTK versions 3.10.0 to 3.10.3 allow attackers to freeze servers by supplying specially crafted regex patterns to search or tokenizer functions. The fix is to upgrade to version 3.10.4 immediately.

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 that manages Python dependencies.
Likely effortAbout 30 minutes per deployment: check the installed version, upgrade NLTK to 3.10.4, test that the application starts, and restart services. Longer if the application runs on many machines or if other dependencies conflict.

Questions to ask your team or supplier

  • Does our application accept user-supplied strings as regex patterns for NLTK search or tokenization, or do we always use hardcoded patterns that we control?
  • If we do accept user patterns, what input validation do we currently have in place, and is it sufficient to reject patterns with many groups or large size?

Message you can forward to the owning team

Security notice: NLTK regex patterns can be made to freeze the server (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-patterns-can-be-made-to-freeze-the/
Source: SecurityElites AI Vulnerabilities Database, record SE-AIV-01419

What is at stake in your AI setup

  • Text processing pipelines that tokenize or search training data or retrieved documents: an attacker could halt model training or retrieval by freezing tokenizers.
  • Chat or search interfaces powered by NLTK text search: an attacker could make the interface unresponsive to all users.

Map where your company uses AI

Who is exposed

  • Applications that accept user input as search patterns in TokenSearcher.findall() or Text.findall()
  • Applications that accept user input as tokenizer patterns in RegexpTokenizer
  • Web services that expose NLTK text search or tokenization to the internet without input validation

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

  • Until NLTK 3.10.4 can be deployed, do not expose TokenSearcher.findall(), Text.findall(), or RegexpTokenizer to untrusted input.
  • If the application must accept user input for search, validate it before passing to NLTK: reject patterns longer than a few hundred characters, reject patterns with more than a few capturing groups, and reject patterns with deep nesting.
  • Add a per-request timeout at the application layer (not inside NLTK) to interrupt long-running text search or tokenization operations and return an error to the user.

Signs it may already have been used against you

  • High CPU usage on a single core that lasts 10 to 60 seconds, coinciding with incoming requests that contain text search or tokenization calls.
  • Exception logs or timeout messages from nltk.text, nltk.tokenize, or the regex module during pattern compilation.
  • Response delays or service unavailability that correlate with requests containing search patterns or tokenizer input.
  • Multiple concurrent requests with similar characteristics (search patterns with many groups or high nesting depth) arriving in a short time window.

Log searches to start from

Find regex compilation timeouts or errors (adapt field names to your logs)Splunk

sourcetype=app_logs ("regex" OR "nltk") ("compile" OR "timeout" OR "CPU") | stats count by host, source_ip

Find spikes in CPU usage on application hosts (adapt field names to your metrics)Elastic

process.name:python* AND cpu_percent:>80 | timechart avg(cpu_percent) by host

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 application code. Check each one for the nltk package using pip list, pip show nltk, or by checking site-packages folders. Record the current version for each.
  2. Check if the application passes untrusted input to NLTK search or tokenizer functionsSearch the application code for calls to TokenSearcher.findall(), Text.findall(), or RegexpTokenizer that accept user-supplied patterns. If found, the application is at risk. If none are found, the application is safe from this issue.
  3. Upgrade NLTK to version 3.10.4In each Python environment that runs the application, upgrade NLTK to 3.10.4 using the package manager (pip, conda, or similar). Verify the upgrade completed without errors.
  4. Confirm the new version is installedRun pip show nltk or python -c 'import nltk; print(nltk.__version__)' in each environment. The output must show version 3.10.4 or later. If it shows an earlier version, the upgrade failed.
  5. Restart the applicationStop and start all services, containers, or processes that use NLTK. Wait for them to fully start and pass health checks before returning to normal traffic.
  6. Check for signs of past attacksReview logs from the past week for unusual CPU spikes, timeouts, or error messages from regex compilation. Look for patterns in the timestamps or source IPs that suggest repeated requests. If found, proceed to the detect and response steps below.
  7. Validate the fix by reviewing code and testingConfirm that the application code does not pass untrusted input as regex patterns. If it does, add input validation to reject patterns with many groups or large sizes. Test the application with normal and edge-case inputs to confirm it works correctly.
  8. Document the action takenRecord which systems were upgraded, the date, and any signs of past attacks. Update the incident or change log.

How to confirm it is fixed: Confirm NLTK version 3.10.4 or later is installed in all Python environments using pip show nltk, and confirm the application or service has restarted successfully.

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 this machinefor this issue

python -c "import nltk; print('NLTK version:', nltk.__version__)"

List installed version across a Python environmentfor this issue

pip show nltk | grep Version

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 difference between match-time and compile-time cost in regex, and why does NLTK's timeout not protect against this issue?A good answer: Compile-time is when the regex engine reads the pattern and builds an internal state machine; match-time is when it scans the corpus. NLTK's timeout only guards match-time, so an attacker can freeze the server during compile-time before any
How can an attacker freeze an NLTK application with a small input?A good answer: An attacker sends a short pattern of many empty groups, such as '()' repeated thousands of times; the regex compiler spends seconds building the internal state machine, consuming one CPU core entirely.
Which NLTK functions are affected and which are safe?A good answer: TokenSearcher.findall(), Text.findall(), and RegexpTokenizer are affected if the pattern comes from untrusted input; hardcoded patterns or patterns from trusted sources are safe.
What is the minimum fix we must apply, and when?A good answer: Upgrade NLTK to version 3.10.4 on all machines running versions 3.10.0 to 3.10.3; do this before the application is exposed to untrusted regex patterns again.

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 patterns can be made to freeze the server (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-patterns-can-be-made-to-freeze-the/

### Why this matters
An attacker who can send text to be searched or tokenized can freeze a server for tens of seconds by forcing expensive regex compilation. This stops the application from responding to other users, and repeated attacks exhaust all CPU cores and crash the service.

### What to do
1. Find where NLTK is installed
2. Check if the application passes untrusted input to NLTK search or tokenizer functions
3. Upgrade NLTK to version 3.10.4
4. Confirm the new version is installed
5. Restart the application
6. Check for signs of past attacks
7. Validate the fix by reviewing code and testing
8. Document the action taken

Full steps: https://securityelites.com/ai-vulnerabilities/cve-2026-129229-nltk-regex-patterns-can-be-made-to-freeze-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 NLTK version 3.10.4 or later is installed in all Python environments using pip show nltk, and confirm the application or service has restarted successfully.
- [ ] 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
  • 3 Dec 2026: Guide updated

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