T05 · Unauthorized Access and Privilege Escalation
- Location
docker-compose.yml:7- Finding
Direct Docker Socket Access Enables Host Privilege Escalation
- Content
View full analysis
Vulnerability Details
File Location:
docker-compose.yml, lines 7-10
Vulnerability Type: Excessive Docker daemon privileges
Risk Level: HighVulnerable Code
yaml volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - proxy-data:/etc/nginx/conf.dTechnical Analysis
The nginx-proxy container receives direct access to the host Docker daemon through
/var/run/docker.sock. Although the socket is mounted with the:rooption, this only makes the socket filesystem entry read-only; it does not restrict the Docker API operations that can be submitted through an already opened Unix socket.A process inside the container may therefore be able to invoke write-capable Docker API endpoints. If the proxy process, image, or one of its dependencies is compromised, an attacker could request the creation of a privileged container, mount the host filesystem, access other containers, or execute commands in containers managed by the daemon.
The socket is legitimately used for automatic container discovery, but unrestricted access to the complete Docker API violates least privilege and creates a container-to-host privilege-escalation boundary.
Attack Path
- An attacker compromises the nginx-proxy process, its container image, or a component running inside the container.
- The attacker opens
/tmp/docker.sockfrom inside the compromised container. - The attacker submits a Docker API request to create a new container with elevated privileges and a bind mount of the host root filesystem.
- The attacker starts that container through the Docker API.
- The attacker accesses or modifies host files through the mounted filesystem, extracts secrets from other containers, or establishes effective root-level control of the Docker host.
Impact Assessment
Successful exploitation could provide effective root-equivalent control over the Docker host. The attacker could:
- Read or modify host files.
- Create privileged containers ...[truncated 394 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace direct Docker socket mounting with a dedicated Docker socket proxy.
- Configure the socket proxy to expose only the read-only API endpoints required for nginx-proxy container discovery, such as narrowly scoped container, network, and event inspection endpoints.
- Explicitly deny container creation, start, exec, image-management, volume-management, secret-management, and other write-capable endpoints.
- Place the socket proxy on an isolated internal Docker network that is reachable only by nginx-proxy.
- Do not expose the socket proxy over a host port or any externally reachable interface.
- Apply additional container hardening where compatible:
- Run with a read-only root filesystem.
- Drop unnecessary Linux capabilities.
- Enable
no-new-privileges. - Apply restrictive seccomp and AppArmor or SELinux policies.
- Document that the
:romount option does not make the Docker API read-only. - Monitor Docker daemon events for unexpected container creation, privileged containers, host bind mounts, and exec operations.
