Docker Escape
Investigation
# Environment variables
env
# Command path
echo $PATH
ls -al /usr/local/bin
ls -al /usr/local/sbin
ls -al /usr/bin
ls -al /bin
# User enumeration
cat /etc/passwd
cat /etc/shadow
getent passwd
# Networks
cat /etc/hosts
cat /etc/resolv.conf
# Bash history
cat /root/.bash_history
cat /home/<username>/.bash_history
# Interesting Directories
ls -al /etc
ls -al /mnt
ls -al /opt
ls -al /srv
ls -al /var/www
ls -al /var/tmp
ls -al /tmp
ls -al /dev/shm
# Cron
cat /etc/cron*
crontab -l
# Process
ps aux
ps aux | cat
# https://github.com/DominicBreuker/pspy
./pspy64
# Network
ip addr
netstat -punta
ss -ltu
cat /etc/hosts
# Port scan another host
nmap 172.17.0.0/24
nmap 172.17.0.1
for i in {1..65535}; do (echo > /dev/tcp/172.17.0.1/$i) >/dev/null 2>&1 && echo $i is open; done
# SSH
ssh <user>@<another_host>
# Check if docker command is available.
# If not, find the command in the container.
docker -h
find / -name "docker" 2>/dev/null
# Container capabilities
capsh --print
# Enumerate pods
crictl pods
# Investigate Docker socket for containerd
# crictl can be downloaded from https://github.com/kubernetes-sigs/cri-tools
crictl -r unix:///run/containerd/containerd.sock ps
crictl -r unix:///run/containerd/containerd.sock images
crictl -r unix:///run/containerd/containerd.sock container lsAccess Another Host
Import Required Binary from Local Machine
SSH Login
Mounting
1. List Disks/Mounted Folders
2. Mount Folder
Gain Access to Mounted System
Privilege Escalation to Root
Run Vulnerable Docker Image
Download Interesting Files
Run Existing Docker Image
1. Check if current user belongs to "docker" group
2. List Docker Images
3. Start Container and Get Shell
Docker Socket Escape
Establish Persistence After PrivEsc
Amazon Elastic Container Registry (ECR) Public Gallery
1. Run the Docker Container
2. Get Sensitive Information in the Container
3. Get Sensitive Information in Local Machine
References
Last updated