CVE-2025-71408
High · 7.8CVSS
7.8
EPSS
0.3%
Published
Jul 24, 2026
CISA due date
—
Cloudanix analysis
A programming library used for text analysis can be tricked into running attacker-chosen commands if someone feeds it specially crafted instructions when it is started from the command line.
- Exploitation
- Local Privilege
- Attacker needs
- Local User
- Complexity
- Low
- Impact
- Full Compromise
- Component
- Library
- Class
- RCE
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
The vulnerability allows arbitrary Python code execution when nltk.collocations is invoked directly as a script; the __main__ block passes unsanitized command-line arguments as suffixes to BigramAssocMeasures and feeds them to eval() without allowlisting, permitting escape to full Python execution including os module calls.
Why it matters to the business
Attackers who can supply command-line arguments to the affected NLTK script can run arbitrary code on the host, leading to data theft, system takeover, or use as a foothold in automated pipelines and developer environments that invoke the module directly.
How an attack unfolds
An attacker supplies a crafted Python expression on the command line that breaks out of the intended attribute access, executes arbitrary statements, and spawns OS commands; because the code path is reached only on direct script invocation, the attack requires the ability to control arguments passed to collocations.py.
How to fix it
Upgrade NLTK to version 3.9.3 or later; avoid invoking collocations.py directly with untrusted arguments; wrap or replace direct script calls with safe API usage that does not expose eval to user input.
How to confirm the fix worked
Confirm NLTK version is 3.9.3 or newer via pip show or equivalent; test that direct invocation of collocations.py with suspicious arguments no longer results in code execution; review any automation or scripts that call the module directly.
Typical attack path
- Identify an environment where nltk/collations.py is executed directly with externally influenced arguments
- Craft a command-line argument containing a Python expression that escapes the BigramAssocMeasures lookup and invokes eval
- Include import and execution of the os module or other dangerous builtins to achieve code execution
- Trigger the script to execute the payload and obtain a shell or perform follow-on actions
How to detect it
Review process execution logs, shell history, and application logs for invocations of collocations.py or python -m nltk.collocations containing unusual Python syntax, import statements, or os module references; inspect any scheduled jobs or developer tooling that pass arguments to the module.
- collocations.py
- BigramAssocMeasures
- eval(
- import os
What your security team should do
- Immediately upgrade all NLTK installations to 3.9.3 or later
- Audit code and CI/CD pipelines for direct execution of nltk/collations.py or similar scripts with variable input
- Add allow-listing or input validation around any remaining direct script invocations
- Monitor for new releases and apply updates within standard change windows given the local attack vector
The record
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 packages
| Ecosystem | Package | Introduced | Fixed |
|---|
Related vulnerabilities
- CVE-2026-44344 Chamilo LMS is an open-source learning management system. CWE-95
- CVE-2026-115943 Spreadsheet::XLSX versions before 0.19 for Perl allow code execution via string eval of… CWE-95
- CVE-2026-90872 Improper neutralization of directives in dynamically evaluated code in the Manager web… CWE-95
- CVE-2026-119121 Crawl4AI from 0.9.0 before 0.9.5 contains a JavaScript injection vulnerability in the… CWE-95
- CVE-2026-44179 XWiki Remote Macros provides XWiki rendering macros that are useful when migrating… CWE-95
- CVE-2026-79678 A flaw was found in FreeIPA's idp-add command, where insufficiently validated… CWE-95
- CVE-2026-85165 n8n versions before 2.36.2 contain an expression sandbox bypass vulnerability where free… CWE-95
- CVE-2026-65643 Eval injection in cPanel 11.138.0.0 and earlier allows remote authenticated users to… CWE-95