CVE-2025-71408: NLTK < 3.9.3 Eval Injection via collocations.py Command-Line Arguments
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 Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
nltkto a version that resolves this vulnerability.Fixed in 3.9.3 - Compensating control
Do not invoke collocations.py directly with user-controlled command-line arguments (suffixes); ensure any CLI arguments passed to nltk.collocations are not attacker-controlled or are blocked at the input/usage boundary.
Event History
Frequently Asked Questions
What is the severity of CVE-2025-71408?
CVE-2025-71408 has a severity rating of 8.5, classified as high.
How do I fix CVE-2025-71408?
To mitigate CVE-2025-71408, upgrade NLTK to version 3.9.3 or later.
What is CVE-2025-71408?
CVE-2025-71408 is an eval injection vulnerability in the NLTK collocations module allowing execution of arbitrary Python code through command-line arguments.
Who is affected by CVE-2025-71408?
Users of NLTK versions prior to 3.9.3 are affected by CVE-2025-71408.
What can an attacker do with CVE-2025-71408?
An attacker can exploit CVE-2025-71408 to execute arbitrary Python code by manipulating command-line arguments.