Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessReach stata_do MCP tool or CLI
-
DeliverySupply crafted log_file_name payload
-
ExploitBreak out of quoted log path
-
ExecutionInject Stata shell command
-
PersistStata executes OS command
-
ImpactRemote 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 |
| 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 |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv2 – 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)
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
Affected Packages
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
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
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.
Primary rating from Vendor (https://github.com/SepineTam/stata-mcp).
CVSS VectorVendor: https://github.com/SepineTam/stata-mcp
Lifecycle Timeline
2DescriptionCVE.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:
commands = f"""
capture log close
{self.generate_log_command(log_file, is_replace)}
...
do "{dofile_path}"
...
"""The generate_log_command method returns:
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:
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:
{
"dofile_path": "test.do",
"log_file_name": "'; shell echo pwned > /tmp/pwned.txt; '"
}The generated Stata commands become:
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
shellcommand 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
- Apply strict allowlist validation to
log_name(only alphanumeric, underscore, dot, hyphen; max 128 chars) - Resolve and verify the constructed log path remains within the intended log directory
- Consider generating safe internal filenames (e.g., UUIDs) instead of accepting user-defined log names for command construction
- Apply similar sanitization to
dofile_pathbefore embedding it into Stata command strings
References
- Issue: #74
- Fix commit: https://github.com/SepineTam/stata-mcp/commit/e6f945941ae0c7cf5e74a428e0b3dc82b396382f
Executive ViewAI
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.
Vendor-released patch: 1.17.3
Threat Intelligence Overview
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.
What every action level means
SSVC AssessmentENISA
Priority Score
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.
Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t
BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser
pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi
The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python
BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica
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
pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.
Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301
In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse
Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to
Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/
pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne
EUVD-2026-46426
GHSA-4p62-hqp5-g644
NVD
CVE.org
EPSS
Exploit-DB