Cloudanix VulnDB

CVE-2025-71408

High · 7.8

CVSS

7.8

EPSS

0.3%

Published

Jul 24, 2026

CISA due date

—

Cloudanix analysis

Next patch cycle SSVC: Track

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.

Exploit Available
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

  1. Identify an environment where nltk/collations.py is executed directly with externally influenced arguments
  2. Craft a command-line argument containing a Python expression that escapes the BigramAssocMeasures lookup and invokes eval
  3. Include import and execution of the os module or other dangerous builtins to achieve code execution
  4. 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