Severity:

HIGH RISK

(7.3)

OS Command Injection in docker-mcp-server HTTP Interface

CVE-2026-5741

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-77, CWE-78

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.3)

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

docker-mcp-server up to version 0.1.0 contains an OS command injection flaw in its HTTP interface, specifically within the stop_container, remove_container, and pull_image functions.

Remote attackers can send crafted HTTP requests that cause unvalidated input to be passed into shell commands, potentially allowing arbitrary command execution on the host running the server.

Affected context

This vulnerability occurs in the HTTP interface of docker-mcp-server when requests that control Docker lifecycle operations (stopping, removing containers, pulling images) are handled by functions that construct shell commands from request parameters.

It is relevant where the service is reachable over a network (e.g., exposed HTTP endpoint or reverse proxy) and where request data is used to influence Docker-related commands executed on the underlying operating system.

Any deployment that passes user-controlled values into these operations without strict validation and without avoiding shell invocation is at risk.

Exploit preconditions

  • Attack surface: Network-accessible HTTP interface of docker-mcp-server.
  • Required access: Ability to send HTTP requests to the server; no strong assumptions can be made about authentication or authorization from the description.
  • Trigger point: Invocations of stop_container, remove_container, or pull_image in src/index.ts that build OS command strings using request parameters.
  • Why exploitation is possible: User input is concatenated or interpolated into shell commands without adequate sanitization, quoting, or use of parameterized command execution APIs, enabling injection of additional commands or arguments.

Why this happens

The core issue is the construction and execution of shell commands from untrusted HTTP request data.

In the affected functions, values derived from client inputs (such as container identifiers or image names) are likely interpolated into command strings and executed through APIs that invoke a shell (e.g., child_process.exec or similar).

This pattern corresponds to CWE-77/78: Command Injection, where failure to treat input as pure data allows attackers to escape the intended argument context and inject arbitrary OS-level commands.

Potential impact

  • Remote execution of arbitrary commands with the privileges of the docker-mcp-server process.
  • Unauthorized management of Docker containers and images, including stopping or deleting critical services.
  • Lateral movement within the host environment or adjacent containers.
  • Exfiltration or modification of sensitive data accessible from the host.
  • Deployment of malicious containers or images as part of a broader compromise.

General mitigation guidance

Effective mitigation centers on treating all client-provided data as untrusted and avoiding shell invocation for container management tasks.

Recommended defensive patterns include:

  • Using parameterized command execution APIs that do not invoke a shell, passing arguments as arrays rather than concatenated strings.
  • Strictly validating and whitelisting acceptable values for container names, IDs, and image references, rejecting any input that falls outside expected formats.
  • Encapsulating Docker operations behind a minimal, well-typed interface rather than constructing raw commands in request handlers.
  • Running the service with the least necessary OS and Docker privileges to limit the blast radius of a compromise.
  • Introducing secure-by-default defaults, such as denying operations by default and requiring explicit configuration for remote management endpoints.

How teams detect issues like this

Detection typically involves both code-level review and runtime monitoring.

Useful approaches include:

  • Static analysis rules that flag usage of shell-executing functions (exec, execSync, spawn with shell: true, etc.) when they incorporate request-derived variables or string concatenation.
  • Manual code review focused on HTTP handlers, looking for direct interpolation of request parameters into command strings or subprocess calls.
  • Security testing (including fuzzing and dynamic analysis) targeting endpoints that manage containers or images to detect unexpected command behavior.
  • Runtime monitoring and logging of executed commands to identify unusual arguments or patterns indicative of injection attempts.

Sources

SourceLink
github.comgithub.com/BruceJqs/public_exp/issues/1
github.comgithub.com/suvarchal/docker-mcp/issues/3
vuldb.comvuldb.com/submit/786948
vuldb.comvuldb.com/vuln/355748
vuldb.comvuldb.com/vuln/355748/cti

Frequently asked

questions

Yes. The issue lies in the HTTP interface, so any attacker who can send requests to the exposed docker-mcp-server endpoint may be able to exploit the command injection.

The attacker needs network access to the service. Whether authentication is required depends on the specific deployment, but the described weakness does not rely on insider access alone.

Replace shell-based command construction with safe, parameterized subprocess APIs or direct Docker SDK calls, combined with strict validation of all user-supplied identifiers and image names. Avoid any string concatenation into shell commands.

Adopt a policy of never constructing shell commands from user input, enforce input validation on all external interfaces, include security-focused code reviews for management endpoints, and use automated static analysis to catch command injection patterns early in development.

Find out what's already
exploitable in your codebase.