MediumGHSA-8mpw-7fpc-4gqjCVE-2026-81725PYSEC-2026-3752

NLTK: Pl196xCorpusReader has quadratic ReDoS on malformed TEI blocks

Published 8 Sept 2026 · Updated 8 Sept 2026

Is your project on an affected nltk?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected package

nltkPyPI
Affected
<3.10.3
Fixed in
3.10.3
Update to the fixed version for your release line, for example:pip install 'nltk>=3.10.3'

Details

Summary

Pl196xCorpusReader still parses whole TEI blocks with multiple lazy regexes over attacker-controlled text. A malformed file with many opening tags and no matching closing tags forces repeated rescans and produces quadratic CPU growth in public reader APIs.

Details

  • Vulnerability type: Regular-expression denial of service
  • Affected component: nltk.corpus.reader.pl196x.TEICorpusView.read_block and Pl196xCorpusReader public methods
  • Affected versions: Published 3.9.4 and current source v3.10.0-rc2 both reproduced.
  • Patched versions: Not yet patched
  • Root cause: Lazy .*? whole-block regexes rescan untrusted XML-like blocks from each opening-tag position.

The parser uses regexes for paragraphs, sentences, and word tags across the whole <text> block. When the attacker supplies many unmatched opening tags, each attempt scans toward the end of the block and fails, then restarts from the next opening tag. There is near four-times runtime growth each time the number of malformed <p> tags doubled, through normal public calls such as words() and tagged_words().

PoC

Preconditions

  • The application parses attacker-influenced PL196X or TEI-like corpus files through public reader APIs.

Steps 1. Create a corpus file with a valid header followed by a <text> block that contains many opening tags and no matching closing tags. 2. Instantiate Pl196xCorpusReader on that corpus. 3. Call words() or tagged_words() and measure elapsed time as the malformed tag count doubles. 4. Observe near quadratic growth instead of near-linear behavior.

Minimal reproducible excerpt

size=1000 0.014s
size=2000 0.057s
size=4000 0.231s
size=8000 0.927s

Impact

A consumer that accepts attacker-influenced corpus files can be forced into heavy CPU use and parser-thread stalling before the application concludes the input contains no valid content.

Remediation

Replace the whole-block lazy-regex parser with a linear parser or bounded tokenizer, and add regression tests that assert near-linear behavior on malformed inputs with many unmatched tags.

Is GHSA-8mpw-7fpc-4gqj in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected nltk, and gives you the command that fixes it.

More advisories for nltk

  • HighCVE-2026-128134NLTK dot2img runs Graphviz 'dot' without the trusted-exec chokepoint, enabling local code execution via a writable PATH element · 16 Nov 2026
  • MediumCVE-2026-126302NLTK: Symlink escape in chat80.sql_query bypasses the pathsec data-root sandbox to read out-of-root SQLite databases · 16 Nov 2026
  • MediumCVE-2026-126296NLTK: Path Traversal in save_maxent_params / load_maxent_params Allow Arbitrary File READ/WRITE · 16 Nov 2026
  • HighCVE-2026-126299NLTK: Quadratic-time CPU denial of service in CCG lexicon parser (fromstring) on wide bracket bodies and operator chains · 14 Nov 2026
  • HighCVE-2026-126298NLTK: Quadratic-time CPU denial of service in Tree.chomsky_normal_form right-factor binarization via list.pop(0) · 14 Nov 2026
  • HighCVE-2026-126297NLTK: Quadratic-time CPU denial of service in ConllCorpusReader SRL instance builder via nested span rescan · 14 Nov 2026
All 64 advisories for nltk

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.