Description
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.
Affected products
| Vendor | Product | Affected | Fixed |
|---|---|---|---|
| ntlk | ntlk | < 3.9.3 | 3.9.3 |
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 14 | nltk | 3.9.3-1 | — |
| Debian 13 | nltk | No fix yet | — |
| Debian 12 | nltk | No fix yet | — |
Ubuntu
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu Pro 26.04 LTS | nltk | No fix yet | — |
| Ubuntu Pro 24.04 LTS | nltk | No fix yet | — |
| Ubuntu Pro 22.04 LTS | nltk | No fix yet | — |
Show 4 more (older releases, extended support, other products)Fewer releases
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu Pro 20.04 LTS | nltk | No fix yet | — |
| Ubuntu Pro 18.04 LTS | nltk | No fix yet | — |
| Ubuntu Pro 16.04 LTS | nltk | No fix yet | — |
| Ubuntu Pro 14.04 LTS | nltk | No fix yet | — |
Affected packages
| Ecosystem | Package | Affected | Fixed | Record |
|---|---|---|---|---|
| PyPI | nltk | < 3.9.3 | 3.9.3 | GHSA-848c-c2cx-j7qx |
References
- Researcher Disclosure technical-description exploit
- NLTK 3.9.3 Release Notes release-notes patch
- Pull Request issue-tracking patch
- Patch Commit patch
- https://www.vulncheck.com/advisories/nltk-eval-injection-via-collocations-py-command-line-arguments third-party-advisory