CVE-2026-129231
## Summary `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. ## Root Cause The `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. ```text Affected function: nltk.data.SeekableUnicodeStreamReader.readline Loop with per-iteration full-buffer rescan: nltk/data.py:1968-2000 chars += new_chars; lines = chars.splitli
Properties
- Summary
- NLTK: Quadratic-time DoS in SeekableUnicodeStreamReader.readline on an unterminated corpus line via per-iteration full-buffer rescan
- Severity
- medium
- Nvd fetched at
- 2026-11-22T12:30:49.958423+00:00
- Epss score
- 0.00479
- Cvss score
- 5.3
- Cvss severity
- MEDIUM
- Retrieved at
- 2026-11-22T12:32:26+00:00
- Ghsa published
- 2026-11-19T23:48:39Z
- Source url
- https://github.com/advisories/GHSA-q4c8-9gwf-255x
- Ghsa updated
- 2026-11-19T23:48:40Z
- Ghsa id
- GHSA-q4c8-9gwf-255x
- Last source
- FIRST EPSS
- Score
- 5.3
- Cvss version
- 3.1
- Cve id
- CVE-2026-129231
- 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-19T19:29:21+00:00
- Name
- CVE-2026-129231
- Is ghsa only
- false
- Vector
- CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Related Entities (4)
HAS_WEAKNESS (2)
AFFECTS (1)
VULNERABLE_TO (1)
Related research
Explore deeper with Ninja Signal's threat intelligence graph