{"vuln_id":"GHSA-q4c8-9gwf-255x","aliases":["CVE-2026-129231"],"description":"NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan","published_at":"2026-11-19T23:48:39Z","modified_at":"2026-11-20T00:00:04.080602Z","first_seen_at":"2026-11-21T19:15:19.367504Z","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-q4c8-9gwf-255x"},"matched_alias":null,"items":[{"id":10699,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-q4c8-9gwf-255x: NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan","summary":"NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan\n\n## Summary\n\n`SeekableUnicodeStreamReader.readline` in `nltk/data.py` assembles a line by repeatedly reading a block, appending it to a growing `chars` buffer, and recomputing `chars.splitlines(True)` over the entire buffer on every loop iteration. The read block size doubles only until it caps at 8000 characters, so for a single unterminated line of N characters the loop runs about N/8000 iterations and iteration k re-scans roughly 8000*k characters, giving O(N^2) total work. The default `size=None` used on the line-oriented corpus-reader read path means the early break never fires before end of file. An attacker who supplies a corpus file containing one very long line with no newline can force quadratic CPU consumption in the reader's process. This is the same growing-buffer re-scan algorithmic-complexity class the project already treats as advisory-worthy in sibling corpus readers.\n\n## Root Cause\n\nThe `readline` loop violates the expectation that reading a line costs time linear in the line length. On each pass it executes `chars += new_chars; lines = chars.splitlines(True)`, scanning the whole accumulated buffer again rather than only the newly read block. Because `readsize` is capped at 8000 (`nltk/data.py:1997-1998`), the number of iterations grows linearly with the line length while each iteration's scan cost also grows linearly, producing quadratic total cost. The loop exits only on end of file or when `size is not None`; since the line-oriented block readers call `stream.readline()` with no argument, `size` defaults to `None` (`nltk/data.py:1942`) and that early break is unreachable on this path. There is no length cap on the assembled line and no wall-clock backstop, because no regular expression is involved on this path and the `nltk.redos` timeout therefore does not apply.\n\n```text\nAffected function: nltk.data.SeekableUnicodeStreamReader.readline\nLoop with per-iteration full-buffer rescan: nltk/data.py:1968-2000\n  chars += new_chars; lines = chars.splitlines(True)   (nltk/data.py:1977-1978)\n  readsize *= 2 capped at 8000                          (nltk/data.py:1997-1998)\nDefault size=None on the corpus-view path:              nltk/data.py:1942\nReachable via read_line_block/read_whitespace_block/read_wordpunct_block/\n  read_blankline_block in nltk/corpus/reader/util.py, through _open's\n  SeekableUnicodeStreamReader construction.\n```\n\n## Impact\n\nAn attacker who controls the bytes of a corpus file processed by a line-oriented NLTK corpus reader (encoding set, which is the common case) can craft one arbitrarily long unterminated line. Reading that line pins a single CPU core for time quadratic in the line length. The effect is recoverable CPU-availability degradation in the processing worker, not a crash: memory use remains linear and the operation completes once the buffer is exhausted. Because the constant factor is bounded by the 8000-character read cap, a meaningful denial of service requires a large crafted file, which keeps the severi\n\nAffected: PyPI:nltk\n\nFixed in: 3.10.4\n\nReferences:\nhttps://github.com/nltk/nltk/security/advisories/GHSA-q4c8-9gwf-255x\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-129231\nhttps://github.com/nltk/nltk/pull/3895\nhttps://github.com/nltk/nltk/commit/002bcf714ef8cb8baf94436f4be73e5516914412\nhttps://github.com/nltk/nltk\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4","url":"https://osv.dev/vulnerability/GHSA-q4c8-9gwf-255x","published_at":"2026-11-19T23:48:39Z","updated_at":"2026-11-20T00:00:04.080602Z","fetched_at":"2026-11-21T19:15:55.946113Z","severity":"medium","cvss_score":5.3,"epss":0.00479,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-129231","vuln_ids":["CVE-2026-129231","GHSA-Q4C8-9GWF-255X"],"tags":["osv","pypi","fix-available"],"cluster_id":2155,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10699","html":"https://vulnwatch.ve1ve2.com/item/10699"}},{"id":2364,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-q4c8-9gwf-255x / CVE-2026-129231: NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan","summary":"NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan\n\n## Summary\n\n`SeekableUnicodeStreamReader.readline` in `nltk/data.py` assembles a line by repeatedly reading a block, appending it to a growing `chars` buffer, and recomputing `chars.splitlines(True)` over the entire buffer on every loop iteration. The read block size doubles only until it caps at 8000 characters, so for a single unterminated line of N characters the loop runs about N/8000 iterations and iteration k re-scans roughly 8000*k characters, giving O(N^2) total work. The default `size=None` used on the line-oriented corpus-reader read path means the early break never fires before end of file. An attacker who supplies a corpus file containing one very long line with no newline can force quadratic CPU consumption in the reader's process. This is the same growing-buffer re-scan algorithmic-complexity class the project already treats as advisory-worthy in sibling corpus readers.\n\n## Root Cause\n\nThe `readline` loop violates the expectation that reading a line costs time linear in the line length. On each pass it executes `chars += new_chars; lines = chars.splitlines(True)`, scanning the whole accumulated buffer again rather than only the newly read block. Because `readsize` is capped at 8000 (`nltk/data.py:1997-1998`), the number of iterations grows linearly with the line length while each iteration's scan cost also grows linearly, producing quadratic total cost. The loop exits only on end of file or when `size is not None`; since the line-oriented block readers call `stream.readline()` with no argument, `size` defaults to `None` (`nltk/data.py:1942`) and that early break is unreachable on this path. There is no length cap on the assembled line and no wall-clock backstop, because no regular expression is involved on this path and the `nltk.redos` timeout therefore does not apply.\n\n```text\nAffected function: nltk.data.SeekableUnicodeStreamReader.readline\nLoop with per-iteration full-buffer rescan: nltk/data.py:1968-2000\n  chars += new_chars; lines = chars.splitlines(True)   (nltk/data.py:1977-1978)\n  readsize *= 2 capped at 8000                          (nltk/data.py:1997-1998)\nDefault size=None on the corpus-view path:              nltk/data.py:1942\nReachable via read_line_block/read_whitespace_block/read_wordpunct_block/\n  read_blankline_block in nltk/corpus/reader/util.py, through _open's\n  SeekableUnicodeStreamReader construction.\n```\n\n## Impact\n\nAn attacker who controls the bytes of a corpus file processed by a line-oriented NLTK corpus reader (encoding set, which is the common case) can craft one arbitrarily long unterminated line. Reading that line pins a single CPU core for time quadratic in the line length. The effect is recoverable CPU-availability degradation in the processing worker, not a crash: memory use remains linear and the operation completes once the buffer is exhausted. Because the constant factor is bounded by the 8000-character read cap, a meaningful denial of service requires a large crafted file, which keeps the severi\n\nAffected packages: pip:nltk\nPatched: nltk 3.10.4","url":"https://github.com/advisories/GHSA-q4c8-9gwf-255x","published_at":"2026-11-19T23:48:39Z","updated_at":"2026-11-19T23:48:40Z","fetched_at":"2026-11-21T19:15:18.416780Z","severity":"medium","cvss_score":5.3,"epss":0.00479,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-129231","vuln_ids":["CVE-2026-129231","GHSA-Q4C8-9GWF-255X"],"tags":["ghsa","pip","CWE-400","CWE-407"],"cluster_id":2155,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2364","html":"https://vulnwatch.ve1ve2.com/item/2364"}},{"id":9042,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-129231: NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Proc…","summary":"NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. Prior to 3.10.4, SeekableUnicodeStreamReader.readline appends each new block to a growing character buffer and reruns splitlines over the entire buffer on every iteration. An attacker-controlled corpus file containing one very long unterminated line therefore causes quadratic CPU consumption in line-oriented corpus readers and can deny service. This issue is fixed in version 3.10.4.\n\nReferences:\nhttps://github.com/nltk/nltk/commit/002bcf714ef8cb8baf94436f4be73e5516914412\nhttps://github.com/nltk/nltk/pull/3895\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4\nhttps://github.com/nltk/nltk/security/advisories/GHSA-q4c8-9gwf-255x\nhttps://github.com/nltk/nltk/security/advisories/GHSA-q4c8-9gwf-255x","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129231","published_at":"2026-11-19T18:18:08.253000Z","updated_at":"2026-11-20T22:17:49.300000Z","fetched_at":"2026-11-21T19:15:31.484694Z","severity":"medium","cvss_score":5.3,"epss":0.00479,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-129231","vuln_ids":["CVE-2026-129231","GHSA-Q4C8-9GWF-255X"],"tags":["CWE-400","CWE-407"],"cluster_id":846,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/9042","html":"https://vulnwatch.ve1ve2.com/item/9042"}}]}