Critical severity9.8NVD Advisory· Published Apr 8, 2026· Updated Apr 14, 2026
CVE-2026-31040
CVE-2026-31040
Description
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.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
stata-mcpPyPI | < 1.13.0 | 1.13.0 |
Affected products
1Patches
152413ceMerge pull request #21 from 123mutouren321414/fix-stata-shell-escape
1 file changed · +23 −0
src/stata_mcp/core/stata/stata_do/do.py+23 −0 modified@@ -65,6 +65,29 @@ def execute_dofile(self, ValueError: Unsupported operating system RuntimeError: Stata execution error """ + # ===== Initial security guard: validate do-file content ===== + def _validate_dofile_content(text: str) -> None: + """ + Initial security guard: reject Stata shell-escape directives + like `!cmd` or `shell cmd` to prevent OS command execution. + """ + dangerous_tokens = ["\n!", "\nshell "] + for token in dangerous_tokens: + if token in text: + raise ValueError( + "Shell-escape commands (!cmd or shell cmd) " + "are disabled for security reasons." + ) + + try: + # Load the do-file content and validate before execution + with open(dofile_path, "r", encoding="utf-8") as f: + dofile_content = f.read() + _validate_dofile_content(dofile_content) + except Exception as e: + return f"There is a security in {dofile_path}, error: {e}" + # ===== End of initial security guard ===== + nowtime = get_nowtime() log_name = log_file_name or nowtime log_file = os.path.join(self.log_file_path, f"{log_name}.log")
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- github.com/SepineTam/stata-mcp/commit/52413cenvdPatchWEB
- github.com/SepineTam/stata-mcp/issues/20nvdVendor AdvisoryIssue TrackingWEB
- github.com/advisories/GHSA-jpcj-7wfg-mqxvghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2026-31040ghsaADVISORY
- github.com/SepineTam/stata-mcp/pull/21nvdIssue TrackingWEB
- github.com/SepineTam/stata-mcp/releases/tag/v1.13.0nvdRelease NotesWEB
News mentions
0No linked articles in our index yet.