Skip to content

security: Command injection risk in Docker exec wrapper (makeDockerExec) #2985

@louisgv

Description

@louisgv

Severity

CRITICAL

Location

packages/cli/src/shared/orchestrate.ts:44

Description

The makeDockerExec function wraps user-controlled commands for Docker container execution. While shellQuote is used, the command passes through multiple shell layers (bash -c inside Docker), which could allow injection if crafted payloads survive the quoting.

Vulnerable Code

export function makeDockerExec(cmd: string): string {
  return \`docker exec ${DOCKER_CONTAINER_NAME} bash -c ${shellQuote(cmd)}\`;
}

Attack Vector

If cmd contains shell metacharacters that survive shellQuote, they could be executed on the host or inside the container. The nested shell execution (docker exec ... bash -c ...) creates multiple interpretation layers.

Recommendation

  1. Use docker exec with array arguments instead of shell string interpolation
  2. Validate that cmd doesn't contain dangerous patterns before wrapping
  3. Avoid nested shell execution layers where possible

Impact

An attacker who can control the cmd parameter could potentially:

  • Execute arbitrary commands inside the container
  • Break out of intended command restrictions
  • Access sensitive data or credentials inside the container

-- security/code-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    safe-to-workSecurity triage: safe for automated processing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions