MEDIUMCVSS v3.1 5.3Vulnerability

CVE-2026-126300

## Summary `TreebankWordTokenizer.span_tokenize` in the NLTK tokenizer package contains an unguarded O(n^2) processing loop in its quote-restoration step. When the method is invoked on text containing a long run of double-quote characters (for example `'"' * n`), it performs a `list.pop(0)` operation once per quote token, and because `list.pop(0)` is O(length), the total cost grows with the square of the input length. An attacker who can supply untrusted text to this public span-tokenization API can force a single request to saturate one CPU core for a prolonged period, degrading availability. No authentication, special configuration, or user interaction is required. ## Root Cause Inside `span_tokenize`, when the input contains double or repeated quotes, the code builds `matched`, a list with one entry per quote occurrence, and then reconstructs tokens in a comprehension that calls `matched.pop(0)` for each token that is a quote. Removing the first element of a Python list is an O(len(list)) operation because all remaining elements are shifted. For an all-quote input the tokenizer produces n quote tokens and `matched` has n entries, so `pop(0)` is called n times, each time on a list of shrinking but still linear length, giving cumulative O(n^2) CPU work. The violated invariant is bounded per-input work: there is no length cap on `span_tokenize` or the underlying `tokenize`, so untrusted input length translates into quadratic processing time. The neighboring `align_tokens` call is linear and is not the quadratic term. ```text Affected function: TreebankWordTokenizer.span_tokenize Source: nltk/tokenize/treebank.py - branch selector at line 203 - matched list built at line 205 - quadratic sink matched.pop(0) at line 209 - linear align_tokens call at line 215 ``` ## Impact An attacker who controls text passed to `TreebankWordTokenizer.span_tokenize` can trigger quadratic CPU work. In the reviewed release, an all-quote input of 128,000 characters takes abou

Properties

Severity
medium
Summary
NLTK: Quadratic CPU exhaustion in TreebankWordTokenizer.span_tokenize via list.pop(0) in quote-restore loop
Nvd fetched at
2026-11-14T00:40:25.638091+00:00
Epss score
0.00509
Cvss severity
MEDIUM
Cvss score
5.3
Retrieved at
2026-11-14T00:51:03+00:00
Ghsa published
2026-11-13T21:08:55Z
Source url
https://github.com/advisories/GHSA-ffr9-mgrr-wcvr
Ghsa updated
2026-11-13T21:08:55Z
Ghsa id
GHSA-ffr9-mgrr-wcvr
Last source
FIRST EPSS
Score
5.3
Cvss version
3.1
Cve id
CVE-2026-126300
Cvss vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
First seen by Signal
2026-11-13T17:31:47+00:00
Is ghsa only
false
Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Published at
2026-11-13T10:17:34.917

Related Entities (4)

AFFECTS (1)

→[Software]pip/nltk

VULNERABLE_TO (1)

←[Software]pip/nltk

Related research

Explore deeper with Ninja Signal's threat intelligence graph

CVE-2026-126300 (CVSS v3.1 5.3) — Ninja Signal Threat Intelligence | Ninja Signal