/

CVE-2026-55581

Severity:

HIGH RISK

(8.4)

OS Command Injection (CWE-78) in mcp-shell MCP Server

CVE-2026-55581

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78, CWE-183, CWE-1188

Impact:

Arbitrary Command Execution

Severity:

HIGH RISK

(8.4)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A command injection vulnerability in mcp-shell allows a caller of the shell_exec MCP tool to bypass the intended executable allowlist by invoking Bash in command mode.

When the server accepts a command containing /bin/bash -c, an attacker may execute arbitrary operating-system commands with the privileges of the mcpuser account.

Affected context

The vulnerability occurs in mcp-shell deployments that use the affected command validation logic and a security configuration allowing /bin/bash. The validation checks only the first command token and does not reject Bash's command-mode flag, allowing a shell interpreter to process additional command text after the allowlisted executable is accepted.

Exploit preconditions

  • Attack surface: The shell_exec MCP tool
  • Required access: Ability to invoke the MCP tool, subject to the deployment's authentication and authorization controls
  • Trigger point: Command validation and execution of a request containing /bin/bash with the -c option
  • Why exploitation is possible: Validation evaluates only the first token and does not block shell command-mode arguments, so attacker-controlled text reaches the shell interpreter outside the intended executable allowlist

Why this happens

The underlying flaw is an incomplete command-validation boundary. The server treats the first token as sufficient evidence that a command is allowed, while permitting an allowlisted shell interpreter to receive arguments that change its behavior.

This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because attacker-controlled input can influence operating-system command execution. It is also related to CWE-183: Permissive List of Allowed Inputs and CWE-1188: Initialization of a Resource with an Insecure Default, because the default policy permits a shell executable without accounting for its command-interpreter modes.

Potential impact

  • An attacker may execute arbitrary commands as the mcpuser account.
  • The application or container runtime could be compromised.
  • Sensitive files, credentials, or environment data may be exposed.
  • An attacker could modify application data or disrupt service operation.
  • Additional compromise could occur if the process has excessive filesystem, network, or host permissions.

General mitigation guidance

Mitigation generally focuses on removing shell interpretation from command execution and making execution policies deny-by-default.

Common defensive patterns include:

  • Avoiding shell interpreters for structured command execution whenever possible.
  • Treating the complete executable and argument vector as policy input rather than validating only the first token.
  • Rejecting shell command-mode flags and other interpreter options unless they are explicitly required and safely constrained.
  • Using narrowly scoped executable and argument allowlists with secure defaults.
  • Reducing input trust through typed command parameters and strict validation.
  • Running the service with least-privilege filesystem, network, and process permissions.
  • Preventing access to sensitive host resources and limiting container capabilities.
  • Applying authorization and auditing controls to every command-execution request.

How teams detect issues like this

Detection approaches can include:

  • Static analysis rules for shell execution APIs, command interpreters, and execution of user-controlled strings.
  • Code review checks for validation that inspects only the first token of a command.
  • Searches for allowlists containing shells such as Bash together with interpreter flags such as -c.
  • Policy checks that require argument-aware command validation and deny-by-default executable configuration.
  • Runtime monitoring for unexpected shell processes, command-line arguments, child processes, and access to sensitive paths.
  • Automated security review tools that identify command construction and incomplete input-neutralization patterns.

Sources

SourceLink
github.comgithub.com/sonirico/mcp-shell/commit/f31377fce6ec31114e5a4398c0e5270552bce09f
github.comgithub.com/sonirico/mcp-shell/pull/16
github.comgithub.com/sonirico/mcp-shell/releases/tag/v0.6.0
github.comgithub.com/sonirico/mcp-shell/security/advisories/GHSA-3x77-wg38-92r3

Frequently asked

questions

Exploitability depends on how the MCP server is exposed. A caller able to invoke the shell_exec tool may be able to trigger the issue without direct host access, subject to authentication and authorization controls.

No direct container-shell access is necessarily required. The relevant prerequisite is permission to submit a command through the MCP tool.

Avoid shell interpretation, validate the complete executable and argument vector, and use narrowly scoped, deny-by-default command policies.

Keep shells out of executable allowlists where possible, test interpreter-specific flags, enforce least privilege, and combine static analysis with runtime monitoring and authorization controls.

Find out what's already
exploitable in your codebase.