Résumé
ONYEDIKACHI BERNARDCLOUD · DEVSECOPS · AI
RésuméGet in touch
CASE 26CONTAINERS & KUBERNETES

Docker Socket Exposure

A container had the Docker socket mounted inside it, giving any process in the container full control of the Docker Engine. I confirmed the escape path by creating a new container with the host filesystem mounted and identified the controls to prevent socket exposure.

Status: ASSESSED · VERIFIED

DOMAIN
Containers & Kubernetes
PLATFORM
Docker, Linux
SEVERITY
Critical
OUTCOME
Socket escape path confirmed

TOOLS

DockerDocker EngineLinuxUnix SocketsAlpine LinuxBashBind MountsContainer Runtime
RESULT
BEFOREDocker socket mounted in container
AFTEREscape path documented
01

Objective

I set out to assess whether a Docker socket mounted inside a container could allow an attacker to interact with the Docker Engine and access the underlying host filesystem.

02

Scenario

A container had /var/run/docker.sock mounted as a volume, which is sometimes done for monitoring or management tools. I wanted to determine whether this access could be used to escape the container and reach the host.

03

What I found

FINDING 01 (CRITICAL): DOCKER SOCKET ACCESSIBLE FROM INSIDE THE CONTAINER

The Docker Unix socket was mounted at /var/run/docker.sock inside the container, and the container's user had permission to interact with it.

socket-permissionsSOCKET EXPOSED
Socket path:         /var/run/docker.sock
Permissions:         rw-rw---- (root:docker group)
Container access:    Full Docker Engine control

FINDING 02 (CRITICAL): CONTAINER COULD CREATE NEW CONTAINERS WITH HOST FILESYSTEM ACCESS

With access to the Docker socket, the container could instruct the Docker Engine to create a new container with the host's root filesystem bind-mounted. This provided direct access to the host filesystem from inside the new container.

escape-resultHOST ACCESS
New container:       Alpine with host / mounted at /mnt
Host filesystem:     Fully accessible
Escape method:       Docker socket to Engine to new container

Any process that can reach the Docker socket effectively has root-equivalent access to the host.

04

What I did

  1. Confirmed socket access

    I verified that /var/run/docker.sock was mounted and accessible from inside the container.

  2. Checked available images

    The Alpine image was available locally on the Docker Engine.

  3. Tested the escape path

    I used the Docker CLI to create a new container with the host filesystem bind-mounted and confirmed full host access.

  4. Documented the exposure

    The Docker socket mount gave the container root-equivalent access to the host.

EVIDENCE

TEXT
# Socket exposure assessment
Socket:            /var/run/docker.sock (mounted in container)
Docker Engine:     Accessible via socket
Escape:            New container created with host filesystem mounted
Host access:       Confirmed (root filesystem readable)
05

Validation

A new container with the host filesystem mounted was created through the Docker socket, and host-level files were accessible. The escape path was confirmed.

06

Before and after

CONTROLBEFOREAFTER
Docker socket mountExposed inside containerEscape documented; removal recommended
Container access to EngineFull controlRecommended: remove socket mount
Host filesystemAccessible via new containerRecommended: no bind mounts of /
Socket permissionsRead-writeRecommended: do not mount into application containers
07

What I recommend

  1. 01Never mount the Docker socket into application containers. If monitoring tools need it, use a read-only socket proxy with restricted API access.
  2. 02Run containers with the minimum privileges needed; do not add users to the docker group inside containers.
  3. 03Use container runtimes that do not expose the management socket to workloads (such as rootless Docker or Podman).
  4. 04Monitor for containers that mount /var/run/docker.sock and alert on new instances.
  5. 05Review all container configurations for unnecessary volume mounts.

“The Docker socket is not just a communication interface. Access to it can provide effective control over the Docker Engine and potentially allow a compromised container to cross the host isolation boundary.”

WHAT I LEARNED

SKILLS IT PROVES

  • Docker Security
  • Container Security
  • Container Escape
  • Linux Security
  • Unix Socket Security
  • Docker Engine Security
  • Privilege Escalation
  • Vulnerability Assessment
  • Host Isolation
  • Access Control
  • Least Privilege
  • Container Runtime Security
View my labs on GitHub