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, orpull_imageinsrc/index.tsthat 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,spawnwithshell: 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.

