{"vuln_id":"GHSA-gpwc-27cw-rh9r","aliases":["CVE-2026-126301"],"description":"NLTK: Quadratic CPU exhaustion in LegalitySyllableTokenizer.tokenize via unguarded onset reversal loop","published_at":"2026-11-13T21:16:34Z","modified_at":"2026-11-16T14:50:36Z","first_seen_at":"2026-11-21T19:15:20.340373Z","severity":"medium","severity_source":"ghsa","cvss_score":5.3,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","cwe":["CWE-400","CWE-407"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-gpwc-27cw-rh9r"},"matched_alias":null,"items":[{"id":2607,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-gpwc-27cw-rh9r / CVE-2026-126301: NLTK: Quadratic CPU exhaustion in LegalitySyllableTokenizer.tokenize via unguarded onset reversal loop","summary":"NLTK: Quadratic CPU exhaustion in LegalitySyllableTokenizer.tokenize via unguarded onset reversal loop\n\n## Summary\n\n`LegalitySyllableTokenizer.tokenize` in the NLTK tokenizer package contains an unguarded O(n^2) processing loop. When the method is called on a single token that consists of a long run of vowels (for example `\"a\" * n`), it consumes CPU time proportional to the square of the token length. An attacker who can supply an untrusted token to this public tokenizer API can force a single request to saturate one CPU core for a prolonged period, degrading availability of any service that syllabifies attacker-controlled text. No authentication, special configuration, or user interaction is required.\n\n## Root Cause\n\nThe method walks the token in reverse and, on every iteration after the first vowel is seen, evaluates the membership test `char_lower + current_onset[::-1] in self.legal_onsets`. The set `legal_onsets` is built by `onset()`, which returns only the characters up to the first vowel, so every member is vowel-free. For an all-vowel token the first branch can therefore never match, `onset` never becomes `True`, and the reset branch that would clear `current_onset` is never reached. As a result `current_onset` grows by one character on every iteration. Building `current_onset[::-1]` and hashing the resulting string costs O(k) on iteration k, and this is repeated for k from 1 to n, giving total cost O(n^2). The security invariant that is violated is bounded per-token work: there is no length cap on this code path, so untrusted token length translates directly into quadratic CPU consumption.\n\n```text\nAffected function: LegalitySyllableTokenizer.tokenize\nSource: nltk/tokenize/legality_principle.py (membership-test sink at line 133; loop over token[::-1] beginning at line 126)\nHelper establishing the vowel-free onset set: LegalitySyllableTokenizer.onset (nltk/tokenize/legality_principle.py, returns prefix up to first vowel)\n```\n\n## Impact\n\nAn attacker who controls a token passed to `LegalitySyllableTokenizer.tokenize` can trigger quadratic CPU work. In the reviewed release a token of roughly 64,000 vowel characters takes about 1.8 seconds on a single core, and the cost grows with the square of the length, so a token in the hundreds of kilobytes to megabyte range consumes a core for many seconds to minutes. Memory use is linear. The demonstrated capability is single-core CPU exhaustion leading to denial of service or latency degradation in any network-reachable component that syllabifies untrusted input. There is no confidentiality or integrity impact; the effect is availability degradation of the affected process. The plausible operational consequence, where multiple concurrent requests are used, is exhaustion of the available worker pool; this is inferred from the per-request cost and was not itself executed against a live deployment.\n\n## Proof of Concept\n\n`Requires only the released nltk package; no corpus download is needed because the quadratic behavior is driven entirely by the attacker token, not by the size of the legal-onset set.`\n\n1. \n\nAffected packages: pip:nltk\nPatched: nltk 3.10.4","url":"https://github.com/advisories/GHSA-gpwc-27cw-rh9r","published_at":"2026-11-13T21:16:34Z","updated_at":"2026-11-16T14:50:36Z","fetched_at":"2026-11-21T19:15:18.416970Z","severity":"medium","cvss_score":6.9,"epss":0.00574,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-126301","vuln_ids":["CVE-2026-126301","GHSA-GPWC-27CW-RH9R"],"tags":["ghsa","pip","CWE-400","CWE-407"],"cluster_id":2664,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2607","html":"https://vulnwatch.ve1ve2.com/item/2607"}},{"id":5400,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-126301: NLTK from 3.6 before 3.10.4 contains an algorithmic complexity vulnerability in LegalitySyllableTokenizer.tokenize that allows remote attackers to exhaust CPU…","summary":"NLTK from 3.6 before 3.10.4 contains an algorithmic complexity vulnerability in LegalitySyllableTokenizer.tokenize that allows remote attackers to exhaust CPU by supplying long all-vowel tokens. Attackers can submit a token such as a long run of vowels, causing the unguarded onset reversal loop to perform quadratic work and deny service to syllabification components.\n\nReferences:\nhttps://github.com/nltk/nltk/security/advisories/GHSA-gpwc-27cw-rh9r\nhttps://www.vulncheck.com/advisories/nltk-from-3.6-before-3.10.4-quadratic-cpu-exhaustion-via-legalitysyllabletokenizer-tokenize\nhttps://github.com/nltk/nltk/security/advisories/GHSA-gpwc-27cw-rh9r","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-126301","published_at":"2026-11-13T10:17:35.090000Z","updated_at":"2026-11-17T19:17:50.157000Z","fetched_at":"2026-11-21T19:15:31.480927Z","severity":"medium","cvss_score":6.9,"epss":0.00574,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-126301","vuln_ids":["CVE-2026-126301","GHSA-GPWC-27CW-RH9R"],"tags":["CWE-407"],"cluster_id":1456,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/5400","html":"https://vulnwatch.ve1ve2.com/item/5400"}}]}