Skip to content

Security: Command injection via shell=True in WindowsExecutor #19

Description

@GaboITB

Summary

The WindowsExecutor class in docker_executor.py uses asyncio.create_subprocess_shell() with string interpolation, allowing command injection through the project_name parameter.

Location

src/docker_mcp/docker_executor.py, lines 16-20

The project_name comes directly from user input (arguments.get("project_name")) and is injected into a shell command without any sanitization. A malicious project name like test && rm -rf / would be executed by the shell.

Since this MCP server is designed to be used with LLM agents (Claude, Cursor, etc.), a prompt injection attack could exploit this to execute arbitrary commands on the host system.

Suggested Fix

  1. Replace create_subprocess_shell with create_subprocess_exec (takes a list of arguments)
  2. Or validate project_name with a strict regex like ^[a-zA-Z0-9_-]+$
  3. The UnixExecutor already uses create_subprocess_exec correctly — apply the same pattern to WindowsExecutor

Found during a security audit of MCP servers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions