NLTK regex patterns can be made to freeze the server
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 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 that manages Python dependencies. |
| Likely effort | About 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-01419What 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.
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
| Software | Affected versions | Move to |
|---|---|---|
| nltk PyPI | 3.10.0 up to, but not including, 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-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_ipFind 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 hostWritten 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 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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 VersionPin it in requirements.txtupgrade
nltk>=3.10.4Check 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 VersionRequire 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.
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.
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 can run attacker-controlled programs from the current directory High · CVE-2026-129234
The same kind of mistake in other AI tools
- Langflow OSS allows authenticated users to access or change other users' flows High · CVE-2026-127067
- BaaRai ARTEX admin account can be claimed without authentication on first setup Critical · CVE-2026-140422
- BaaRai ARTEX admin login can be guessed without limits or lockouts Critical · CVE-2026-140365
- Model Context Protocol SDK tasks can be read by other clients sharing the store High · CVE-2026-111767
- rmcp: Session memory leak on invalid requests High · CVE-2026-63128
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-129229For 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.