Skip to content
Access control Write-up Intermediate

Only Two Lines Of Code Simple Docker Trick Gives Attackers Host Access

Docker Desktop on Windows and macOS exposes an unauthenticated Docker API endpoint that containers can reach, allowing a malicious container to create a privileged container and mount the host filesystem. An attacker could then read and write arbitrary files on the host, escaping container isolation.

S.Ali Follow

Published on infosecwriteups.com

When we talk about containers, we talk about isolation, where our application runs without inbound and outbound connection unless explicitly configured.

S.Ali, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely Docker Desktop exposes an unauthenticated Docker API endpoint to containers, allowing them to create privileged containers with host filesystem mounts.

Impact

An attacker could gain full read/write access to host files, bypassing container isolation, though on macOS the user may be prompted to approve disk access.

What the attacker needed

Docker Desktop on Windows or macOS; Ability to run a container

The fix

Docker Desktop should be updated to the latest version, and access to the internal API should be blocked from containers.

How it was found

  1. Create a malicious container by sending a request to the exposed Docker API to create a new container that mounts the host drive.
  2. Extract the container ID from the API response.
  3. Start the container, which executes a command that writes to the host filesystem.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Containers are meant to be isolated from the computer they run on, like a box inside a box. This bug meant that a program running inside a container could talk to Docker's control interface without proving who it was, and use it to start another container that had full access to the host's files. So the isolation could be broken and files on the real computer could be changed.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.