Skip to main content

stata-mcp EUVDEUVD-2026-46426

| CVE-2026-47708 CRITICAL
Command Injection (CWE-77)
2026-06-04 https://github.com/SepineTam/stata-mcp GHSA-4p62-hqp5-g644 PYSEC-2026-544
9.3
CVSS 4.0 · Vendor: https://github.com/SepineTam/stata-mcp
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Reach stata_do MCP tool or CLI
  2. Delivery
    Supply crafted log_file_name payload
  3. Exploit
    Break out of quoted log path
  4. Execution
    Inject Stata shell command
  5. Persist
    Stata executes OS command
  6. Impact
    Remote code execution and file write

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Command injection prevention
MITRE ATT&CK

1 technique across 1 tactic: Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires the attacker to control the log_file_name (a.k.a. log_name) argument passed to the stata_do MCP tool or the stata-mcp tool do CLI on a stata-mcp instance older than 1.17.3, and requires that Stata is installed and reachable so the injected log using/shell commands actually run. Per the vendor CVSS (PR:N/UI:N/AC:L) no authentication or user interaction is claimed, so against an exposed or agent-driven interface this is unauthenticated. The practical limiting factor is deployment: MCP servers are commonly bound to localhost and invoked by a trusted AI client, so an attacker must be able to influence tool arguments - for instance via a prompt-injection or untrusted workflow feeding the parameter - rather than merely reaching a public network port. The GuardValidator content scanner does NOT limit this attack, since it inspects do-file contents only and never the log_file_name parameter.

Impact

The signals are mixed and warrant nuance. The vendor CVSS 4.0 base score is 9.3 (Critical) with AV:N/AC:L/AT:N/PR:N/UI:N and full VC/VI/VA:H, implying trivial unauthenticated remote RCE. However, real-world exposure hinges on how the MCP server is deployed: MCP servers are frequently run locally as a subprocess of an AI client rather than exposed to the network, which would push the practical attack vector toward local/adjacent and require an attacker to already influence the tool call (e.g., via a malicious prompt or untrusted do-file workflow). EPSS is low (0.63%, 71st percentile) and there is no KEV listing and no public exploit code, consistent with a niche developer/research tool rather than a mass-exploited internet-facing service. Net: this is a genuine critical-severity code-execution bug that should be patched promptly by anyone running stata-mcp, but its aggregate internet-wide risk is bounded by limited deployment footprint and the local/agent-mediated nature of typical MCP usage, not the 9.3 headline alone.

Exploit ScenarioDerived

An attacker who can supply parameters to the stata_do tool - for example through a malicious prompt to an AI agent using stata-mcp, or by reaching an exposed MCP/CLI endpoint - sets log_file_name to '; shell echo pwned > /tmp/pwned.txt; '. When the server constructs the log using command, Stata parses the injected shell statement and executes it as an OS command, yielding code execution and arbitrary file write. A published proof-of-concept payload demonstrating exactly this exists in the advisory, and with AC:L the injection requires no special timing or race conditions.

Act Now Prioritize within 24-48h. Why: CRITICAL severity.
Patch available 0.6% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv2 – Jul 21, 2026

Command injection in the stata-mcp (MCP-for-Stata) server versions before 1.17.3 lets attackers execute arbitrary Stata and OS commands by supplying a malicious log_file_name to the stata_do MCP tool or stata-mcp tool do CLI. Because the value is interpolated unsanitized into a Stata log using command, an attacker can break out of the quoted string and invoke shell, python, or erase, achieving remote code execution and arbitrary file write while completely bypassing the GuardValidator, which only inspects do-file content. There is no public exploit identified at time of analysis, though the advisory includes a working proof-of-concept payload; EPSS is low at 0.63% (71st percentile).

Earlier versions of this analysis (1)
v1 Jun 04, 2026 - 21:15

Command injection in stata-mcp (MCP-for-Stata) versions prior to 1.17.3 allows attackers to execute arbitrary Stata commands - including the shell directive - by supplying a crafted log_file_name parameter to the stata_do MCP tool or CLI. The flaw bypasses the existing GuardValidator security control, which only inspects do-file content and never examines wrapper parameters, enabling remote code execution and arbitrary file writes via path traversal. Publicly available exploit code exists in the GHSA advisory PoC, though no public exploit identified at time of analysis indicates in-the-wild abuse.

RemediationAI

Vendor-released patch: upgrade stata-mcp to version 1.17.3 or later (fix commit e6f945941ae0c7cf5e74a428e0b3dc82b396382f), which adds a strict allowlist LOG_FILE_NAME_PATTERN = ^[A-Za-z0-9_.-]{1,128}$ plus a _validate_log_name check that also rejects empty, ., and .. path parts to block traversal. See the advisory at https://github.com/SepineTam/stata-mcp/security/advisories/GHSA-4p62-hqp5-g644 and the patch at https://github.com/SepineTam/mcp-for-stata/commit/e6f945941ae0c7cf5e74a428e0b3dc82b396382f. If you cannot upgrade immediately, restrict who can invoke the stata_do tool and never expose the MCP server to untrusted clients or network interfaces (bind to localhost only), and validate or hard-code log_file_name upstream to alphanumeric/underscore/dot/hyphen values - trade-off: this constrains user-chosen log names but eliminates the injection primitive. Also treat dofile_path as untrusted, since the advisory notes it is embedded into the same command string; the maintainer recommends generating internal UUID-based log filenames rather than accepting user-defined names.

Affected VersionsENISA

stata-mcp < 1.17.3

Affected Packages

pypi stata-mcp fix: 1.17.3

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in pypi

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The affected component is stata-mcp, a Python (pip) Model Context Protocol server that wraps the Stata statistical package so AI agents and CLI users can run do-files. In src/stata_mcp/stata/stata_do/do.py, both _execute_unix_like and _execute_windows build a multi-line Stata command block with Python f-strings, embedding a log path derived from the user-supplied log_name inside a log using "..." statement. This is a textbook CWE-77 (Improper Neutralization of Special Elements used in a Command) flaw: Stata treats quotes, newlines, and separators as command boundaries, so an injected "; shell ... sequence is parsed as additional Stata commands. Stata's shell command then reaches the underlying OS, and on Windows the process is spawned with shell=True, compounding exposure. The same routine also lacks path-canonicalization, permitting ../ traversal to write log files outside the intended directory.

Know when Python gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/SepineTam/stata-mcp) PRIMARY 9.3 CRITICAL
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
vuln.today AI 9.8 CRITICAL

Unauthenticated injection via an exposed tool/CLI parameter (PR:N, AC:L) yields full OS command execution, so C/I/A:H; scope unchanged as the injected commands run within the server's own privilege context.

3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
4.0 AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Primary rating from Vendor (https://github.com/SepineTam/stata-mcp).

CVSS VectorVendor: https://github.com/SepineTam/stata-mcp

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
High
Vulnerable system: Integrity
High
Vulnerable system: Availability
High
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

2
Analysis Updated
Jul 21, 2026 - 21:28 vuln.today
v2 - CVSS changed
CVSS changed
Jul 21, 2026 - 21:22 NVD
9.3 (CRITICAL)

DescriptionCVE.org

Summary

The log_file_name parameter in the stata_do API and CLI is directly interpolated into a Stata command string without sanitization. The security guard (GuardValidator) only scans the do-file content but does not validate this parameter. An attacker can inject arbitrary Stata commands (including shell, python, erase, etc.) by crafting a malicious log_file_name containing quotes, newlines, or Stata command separators.

Details

In src/stata_mcp/stata/stata_do/do.py, both _execute_unix_like and _execute_windows construct a Stata command string using Python f-strings:

python
commands = f"""
capture log close
{self.generate_log_command(log_file, is_replace)}
...
do "{dofile_path}"
...
"""

The generate_log_command method returns:

python
log_cmd = f'log using "{log_file.as_posix()}", {replace_clause} {log_type} name({log_type}_log)'

Where log_file is constructed from user-supplied log_name:

python
def generate_log_file(self, log_name: str, extension='log'):
    return self.log_file_path / f"{log_name}.{extension}"

The log_name parameter comes directly from user input (via MCP tool stata_do or CLI stata-mcp tool do) without any validation. Since the path is embedded inside double quotes in a Stata command string, an attacker can break out of the string context and inject arbitrary commands.

Additionally, generate_log_file does not prevent path traversal via log_name, allowing arbitrary file write outside the intended log directory.

Proof of Concept

When calling stata_do via MCP tool with:

json
{
  "dofile_path": "test.do",
  "log_file_name": "'; shell echo pwned > /tmp/pwned.txt; '"
}

The generated Stata commands become:

stata
log using "<log_dir>/'; shell echo pwned > /tmp/pwned.txt; '.log", replace text name(text_log)

Stata interprets this as multiple commands, with shell echo pwned > /tmp/pwned.txt; executed as an arbitrary shell command.

Impact

  • Remote Code Execution via shell command injection
  • Arbitrary file write/overwrite via path traversal in log_name
  • Complete bypass of the security guard, as the guard only validates do-file content, not wrapper parameters

Remediation / Fix

  1. Apply strict allowlist validation to log_name (only alphanumeric, underscore, dot, hyphen; max 128 chars)
  2. Resolve and verify the constructed log path remains within the intended log directory
  3. Consider generating safe internal filenames (e.g., UUIDs) instead of accepting user-defined log names for command construction
  4. Apply similar sanitization to dofile_path before embedding it into Stata command strings

References

  • Issue: #74
  • Fix commit: https://github.com/SepineTam/stata-mcp/commit/e6f945941ae0c7cf5e74a428e0b3dc82b396382f

Executive ViewAI

Why It Matters

stata-mcp versions before 1.17.3 are vulnerable to command injection through unsanitized log file parameters, enabling remote code execution and bypassing critical security validation controls. Organizations using stata-mcp must immediately patch to mitigate this critical risk to systems processing sensitive analytical data.

Business Impact: High
Compensating Controls

Vendor-released patch: 1.17.3

Threat Intelligence Overview

EPSS Score
0.6%
Top 29% exploitable
Prevalence
Rare
niche Stata-specific MCP tool, small research/developer install base
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity CRITICAL
CISA KEV No
Public POC No
EPSS 0.6%
Patch available Yes
Active threat No
Deciding rule
CRITICAL severity
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
Yes
Human Impact
High

Priority Score

47
Low Medium High Critical
KEV: 0
EPSS: +1
CVSS: +46
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

OS command injection occurs when an application passes unsanitized user input directly into system shell commands.

Path traversal exploits occur when applications use user-controlled input to construct file system paths without proper validation.

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-49869 CRITICAL POC
10.0 Jun 26

Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy