VAITP Dataset

← Back to the dataset

CVE-2026-129229

NLTK regex functions allow regexes with many capture groups, causing quadratic compile time and CPU‑DoS.

  • CVSS 7.5
  • CWE-400
  • Resource Management
  • Remote

NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. From 3.10.0 until 3.10.4, TokenSearcher.findall and Text.findall accept caller-controlled regular expressions with an unbounded number of capturing groups throughout the affected range. Starting in 3.10.3, nltk.redos.compile and RegexpTokenizer expose the same compile-time vector. The third-party regex engine compiles group-dense patterns with roughly quadratic cost before the match-time timeout begins, allowing a small unauthenticated request to exhaust CPU and deny service. This issue is fixed in version 3.10.4.

CVSS base score
7.5
Published
2026-11-19
OWASP
A04 Insecure Design
Orthogonal defect classification
Timing/Serialization
Code defect classification
Timing Issues
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
NLTK
Fixed by upgrading
Yes

Solution

Upgrade NLTK to version 3.10.4 or later.

Vulnerable code sample

import nltk
from nltk.tokenize import TokenSearcher

def find_entities(text: str, pattern: str):
    """
    Search for token sequences matching a caller‑controlled regular expression.
    """
    # VULNERABLE: unbounded capturing groups allow ReDoS
    searcher = TokenSearcher()
    return searcher.findall(pattern, text)

Patched code sample

import nltk
from nltk.tokenize import TokenSearcher
from nltk.redos import compile as safe_compile

def find_entities(text: str, pattern: str):
    """
    Search for token sequences using a compiled regex with a timeout to mitigate ReDoS.
    """
    # FIX: compile with timeout to bound regex processing cost
    compiled = safe_compile(pattern, timeout=0.1)
    searcher = TokenSearcher()
    return searcher.findall(compiled, text)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve2026129229,
  title        = {{NLTK regex functions allow regexes with many capture groups, causing quadratic compile time and CPU‑DoS.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-129229},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129229/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.