NLTK vulnerable to Eval Injection via collocations CLI arguments
Published 25 Jul 2026 · Updated 12 Aug 2026
Is your project on an affected nltk?
Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- <3.9.3
- Fixed in
- 3.9.3
pip install 'nltk>=3.9.3'Details
NLTK (Natural Language Toolkit) before version 3.9.3 contains an eval injection vulnerability in the nltk.collocations module that allows an attacker who controls command-line arguments to execute arbitrary Python code. When collocations.py is invoked directly, the __main__ block passes command-line arguments directly to eval() as suffixes of BigramAssocMeasures without allowlist validation or sanitization, enabling an attacker to supply a Python expression that escapes the intended attribute lookup and executes arbitrary code including OS commands via the os module.
Is GHSA-848c-c2cx-j7qx 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
References
- Advisorynvd.nist.gov/vuln/detail/CVE-2025-71408
- Linkgithub.com/nltk/nltk/pull/3465
- Linkgithub.com/nltk/nltk/commit/66f14096d952ec8f04934f515e027534bd4eb0ac
- Linkaydinnyunus.github.io/2026/06/07/command-injection-nltk-collocations-eval
- Packagegithub.com/nltk/nltk
- Linkgithub.com/nltk/nltk/releases/tag/3.9.3
- Linkgithub.com/pypa/advisory-database/tree/main/vulns/nltk/PYSEC-2026-3657.yaml
- Linkwww.vulncheck.com/advisories/nltk-eval-injection-via-collocations-py-command-line-arguments
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.