Big Bugs: Bitbucket Pipelines Kata Containers Build Container Escape
Kata Containers bind-mounted hostPath volumes read-write into the VM share directory, so a process inside the Kata VM could write to mounts that were meant to be read-only in the container. A malicious build job could overwrite the host's docker binary and, via a log symlink race, append semi-controlled data to arbitrary files on the host as root.
Published on bugcrowd.com
Atlassian ran a project on Bugcrowd looking for bugs in their proposed implementation of Kata Containers within the Bitbucket Pipelines CI/CD environment.Ê
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 the hostPath source was bind-mounted read-write into the Kata VM share directory, with the read-only restriction enforced only inside the VM, so VM-level processes could modify the underlying host file.
Impact
A malicious build job could overwrite the host docker binary to alter other tenants' builds on the same node, and could create or append to arbitrary host files as root, though the researcher did not find a suitable script to turn this into full command execution before the fix.
What the attacker needed
Ability to run a build job; privileged DIND container available; Docker auth plugin disabled in test setup
The fix
The vulnerability was fixed by the Kata Containers team.
How it was found
- Escape from the build container to the Kata VM using the privileged Docker-in-Docker service.
- Inspect mounts in the build container and note the read-only kataShared hostPath mount of the docker binary.
- In the Kata VM, write to the corresponding file under the shared containers directory.
- Confirm the docker binary on the container host was modified and affected another build.
- Mount the pod log directory and symlink a container's log file to a target file to create files on the host.
- Trigger kubelet log rotation and race it to make containerd append to an existing file via a symlink.
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.
Kata Containers runs each container inside its own small virtual machine to keep jobs apart. Files from the real host are shared into that machine, and the sharing was set up so the machine could write to files that were supposed to be locked. That let a build job tamper with files on the shared host, including a program other builds would run.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.