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
NLTK (Natural Language Toolkit)to a version that resolves this vulnerability.Fixed in 3.9.3 - Configuration
When collocations.py is invoked directly, ensure command-line arguments passed into eval() as suffixes of BigramAssocMeasures are subject to allowlist validation and sanitization rather than being passed directly to eval().
NLTK nltk.collocations (collocations.py) eval input validation / allowlist = enabled
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.