NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Other MCP servers and tools

CVE-2026-31040: stata-mcp has insufficient validation of user-supplied Stata do-file content that can lead to command execution

highCVSS 4.0 8.7GHSA-jpcj-7wfg-mqxv

stata-mcp, an MCP server that lets AI agents run Stata, forwarded do-file content to Stata unchecked. Stata's shell-escape syntax (`!` lines and the `shell` command) then runs operating-system commands on the host. Versions before 1.13.0 are affected. Upgrade the pip package to 1.13.0.

Published Apr 8, 2026 · Analysis Oct 30, 2026

What an attacker can do

The stata_do tool runs a do-file that a user or an LLM supplies. The reporter found that the server launches Stata with subprocess.Popen using shell=True and passes the file contents on without inspection. A do-file with a line that starts with ! or uses shell executes that command on the machine hosting the server. The ssc_install tool calls stata_do internally, so it is also a path in.

The proof of concept is a do-file with a harmless display line followed by one shell-escape line, saved where the server can read it and then run through stata_do. The reporter tested it on Windows 10 with Stata 17 MP and stata-mcp 1.12.1, and says the escape behaves the same on macOS and Linux.

In practice, anything that can write a do-file or steer the agent into running one reaches code execution as the user running the server. That includes a prompt injection in a dataset, a paper or a web page the agent reads. The CVSS 4.0 vector rates it network-reachable with no privileges and high integrity impact.

Who is affected

The pip package stata-mcp before 1.13.0. The report was filed against 1.12.1. Check the installed version.

pip show stata-mcp
uv pip list | grep stata-mcp

Every setup that exposes stata_do or ssc_install to an agent is in scope.

stata-mcp

Ecosystem
PyPI
Affected
< 1.13.0
Fixed in
1.13.0
Check
pip show stata-mcp

How to fix it

Upgrade to 1.13.0.

pip install --upgrade "stata-mcp>=1.13.0"

The fix is pull request 21 (commit 52413ce). It adds a check that rejects do-files containing !cmd and shell cmd before they run. The maintainers describe it as an initial guard, not a full rewrite. The reporter also advised dropping shell=True, restricting do-file paths to approved directories, and disabling shell escape in Stata. Run the server under a low-privilege account.

How to tell if you were hit

Search do-files that the agent created or ran for lines starting with ! or the word shell. Check shell history and process listings for child processes of the Stata process that you did not expect. Review recent stata_do and ssc_install calls and the do-file paths they used. Compare against files written in the do-file directory near the time of a call. Beam records agent MCP tool calls and shell commands, so stata_do invocations and what followed can be reviewed there.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

A vulnerability was identified in stata-mcp prior to v1.13.0 where insufficient validation of user-supplied Stata do-file content can lead to command execution.

Questions

Which stata-mcp version fixes CVE-2026-31040?

1.13.0. Earlier versions are affected; the report was against 1.12.1.

How does a do-file run an OS command?

Stata allows shell escape: a line starting with ! or the shell command runs a system command. The server passed the file on without checking for them.

Does the fix block all shell escapes?

The maintainers call it an initial guard that rejects !cmd and shell cmd. Keep the server low-privilege and restrict do-file paths too.

Is it exploited in the wild?

No source says so. The EPSS score is 0.0106.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Other MCP servers and tools vulnerabilities

All Other MCP servers and tools entries