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.
Published: 2026-07-24
Score: 8.5 High
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

The vulnerability exists in the Natural Language Toolkit (NLTK) library, where the collocations.py script passes command‐line arguments directly to Python's eval() function without input validation. An attacker who can influence the arguments supplied to the script can inject arbitrary Python code, which then executes as part of the BigramAssocMeasures namespace. This escalation allows the attacker to run OS commands and gain full control of the system that executes the script. The weakness is a classic code injection flaw (CWE‑95).

Affected Systems

Any installation of NLTK version 3.9.2 or earlier is susceptible. The vulnerability is present in all environments where the collocations.py tool is executed directly with user‑supplied command‑line arguments. Upgrading to NLTK 3.9.3 or later removes the vulnerable code. No other products or vendors were specified beyond the NLTK package itself.

Risk and Exploitability

The CVSS score of 8.5 indicates high severity, while the EPSS score of less than 1% suggests a low probability of exploitation today, yet the flaw remains actionable. The vulnerability is not listed in the CISA KEV catalog. Exploitation requires an attacker who controls the command‑line arguments of a locally executed collocations.py invocation, which could be achieved by any user who is able to run the script. The attacker can execute arbitrary Python code and system commands via the os module. The extent to which this leads to system‑wide control is not explicitly mentioned in the CVE description and is inferred from the ability to run OS commands; the risk level is thus high.

Generated by OpenCVE AI on August 4, 2026 at 14:51 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade NLTK to version 3.9.3 or later to eliminate the eval injection path.
  • Disallow or delete direct execution of collocations.py when untrusted command‑line input can be supplied, ensuring the script is only run in controlled environments.
  • If the script must be used with dynamic arguments, validate or sanitize all parameters before they are passed to eval, or replace the eval call with a safer alternative.

Generated by OpenCVE AI on August 4, 2026 at 14:51 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-848c-c2cx-j7qx NLTK vulnerable to Eval Injection via collocations CLI arguments
History

Mon, 27 Jul 2026 20:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'total'}, 'version': '2.0.3'}


Mon, 27 Jul 2026 13:15:00 +0000

Type Values Removed Values Added
First Time appeared Ntlk
Ntlk ntlk
Vendors & Products Ntlk
Ntlk ntlk

Sat, 25 Jul 2026 10:45:00 +0000

Type Values Removed Values Added
Title NLTK < 3.9.2 Eval Injection via collocations.py Command-Line Arguments NLTK < 3.9.3 Eval Injection via collocations.py Command-Line Arguments

Fri, 24 Jul 2026 21:45:00 +0000

Type Values Removed Values Added
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.
Title NLTK < 3.9.2 Eval Injection via collocations.py Command-Line Arguments
Weaknesses CWE-95
References
Metrics cvssV3_1

{'score': 7.8, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H'}

cvssV4_0

{'score': 8.5, 'vector': 'CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N'}


cve-icon MITRE

Status: PUBLISHED

Assigner: VulnCheck

Published:

Updated: 2026-07-27T17:22:48.131Z

Reserved: 2026-07-24T20:57:08.784Z

Link: CVE-2025-71408

cve-icon Vulnrichment

Updated: 2026-07-27T17:22:42.530Z

cve-icon NVD

Status : Analyzed

Published: 2026-07-24T22:16:50.063

Modified: 2026-08-10T13:37:33.607

Link: CVE-2025-71408

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-08-04T15:00:14Z

Weaknesses
  • CWE-95

    Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection')