Skip to content
Race condition Write-up Advanced

Dirty COW Docker Container Escape

A race condition in the Linux kernel's copy-on-write handling (Dirty COW) allowed an attacker to modify read-only memory mappings. By targeting the shared vDSO memory, an attacker could execute shellcode in the context of other processes, including root processes, and escape a Docker container to gain root access on the host.

blog.paranoidsoftware.com

Published on blog.paranoidsoftware.com

Dirty COW is the name for a vulnerability that stems from a race condition in the way that the Linux kernel's memory subsystem handles read only private mappings when a Copy On Write situation is triggered. Copy On Write allows for the sharing of resources rather than the duplication of them.

The author, on blog.paranoidsoftware.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 a race condition in the Linux kernel's memory subsystem when handling read-only private mappings during copy-on-write, allowing modification of the original shared memory.

Impact

An attacker with access to a container could escape it and gain root access on the host, potentially compromising the entire system.

What the attacker needed

Vulnerable Linux kernel; ability to run code in a container

The fix

The Linux kernel was patched to fix the race condition; users should apply kernel updates.

How it was found

  1. Set up a vulnerable Linux instance (e.g., in AWS with a specific AMI).
  2. Start a Docker container running a shell.
  3. Inside the container, edit the exploit payload to set the reverse shell IP and port.
  4. Compile and run the exploit inside the container.
  5. Receive a root shell on the host and access host files.

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.

Dirty COW is a flaw in how the Linux kernel shares memory between programs. When a program tries to change a shared piece of memory, the kernel is supposed to give it a private copy, but a race condition let an attacker change the original shared memory instead. Because containers like Docker rely on the same kernel, an attacker inside a container could use this to run code as root on the host machine.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.