Executive brief
mcp-shell is a Model Context Protocol tool for secure command execution in Docker containers, designed to restrict operators to an allowlist of pre-approved binaries. A flaw in the validation logic allows an attacker to send `/bin/bash -c <arbitrary-command>` to the shell_exec tool and execute any command present in the container—such as `curl`, `wget`, or `env`—outside the allowlist. This works on default deployments with no authentication required, giving an attacker full command execution as the `mcpuser` account.
Technical details
The vulnerability is an OS command injection (CWE-78) stemming from incomplete argument validation in the secure mode enforcer. The default Docker image ships `security.yaml` with `/bin/bash` in the `allowed_executables` list. The validator in `security.go` splits the input command on whitespace and checks only the first token (e.g., `/bin/bash`) against the allowlist; it does not inspect or block shell command-mode flags like `-c`. When `/bin/bash -c id` is submitted, the validator extracts `/bin/bash`, matches it against the allowlist, then passes the entire command to the executor without detecting the `-c` flag. The executor then invokes `exec.CommandContext(ctx, "/bin/bash", "-c", "id")`, which spawns bash with the `-c` flag, executing the arbitrary `id` command as `mcpuser` (UID 1000). No authentication is required, and the vulnerability is present in all default deployments.
Affected products
- sonirico mcp-shell < 0.6.0
Timeline
- 2026-06-14: disclosed
- 2026-06-14: patched: Version 0.6.0 released with fix
- 2026-08-25: advisory