FlawOpen

flawopen.com/Reference/Docker Socket Exposure & Container Privileges

Docker Socket Exposure & Container Privileges

High-Impact Configuration Risk CWE-732 Container Runtime Security
ELI5 — Giving a Workload the Building Control Console

Imagine a building operator who can unlock every service room. A guest may have a restricted badge, but if you also hand them the operator's control console, the badge no longer limits what they can ask the operator to do. A mounted Docker socket can create that mismatch: a process talks to the daemon, and the daemon performs actions with its own authority. The result depends on how that daemon is configured; a rootful daemon usually has much broader host authority than a rootless one.

Target: Docker Engine workloads, build runners, and systems that expose a daemon socket
Vector: Exposing a writable daemon socket or granting broader privileges than a workload needs
Impact: Daemon-level actions; host impact depends on daemon authority, access controls, and runtime configuration
Remediation: Avoid socket access; use an appropriately isolated or rootless builder and drop unneeded capabilities

How Socket Access and Capabilities Change the Threat Model

The Docker Unix socket is an API endpoint for the Docker daemon. A process that can issue requests through it can exercise the authority granted to that daemon; on a default rootful installation, Docker documents daemon control as effectively root-level access. The exact impact still depends on socket permissions, authorization controls, daemon mode, user-namespace settings, and host policy. Separately, CAP_SYS_ADMIN is a broad capability that covers many system-administration operations, but it is not by itself a universal host-escape primitive. The --privileged option grants a much broader set of permissions and devices, so avoid it for ordinary workloads.

compose.yaml (Overexposed Workload)Vulnerable
# RISKY: This workload receives the host daemon control socket.
services:
  build-runner:
    image: example-build-runner:stable
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
compose.yaml (Reduced Workload Privileges)Hardened
# HARDENED: Keep daemon control outside the application workload.
services:
  app:
    image: example-app:stable
    user: "10001:10001"
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    tmpfs:
      - /tmp:rw,noexec,nosuid,size=64m

A Typical Exposure Path

Defensive Engineering Checklist

Primary sources

Explore related security topics and post-mortems:Complete Security Directory →
See also GitHub Actions Script Injection: Safe Workflow Inputs Cosign GHSA-fx35-mq7g-6g98: Bundle Verification Bypass Dependency Confusion: Risks and Defenses