Escaping Docker
Enumeration
Enumeration
Check for the Presence of .dockerenv
Finding this file can confirm you're inside a container and give insight into the container environment.
Tools like
nsenter
ordocker-exploit
can be used to attempt escaping the container.If the user is in the
docker
group, attempt to run the following command to mount the host filesystem and gain access to the host:
Identify Active Containers
List all running containers:
Check for containers running with elevated privileges (
--privileged
,--cap-add
).Look for containers that share host namespaces or file systems.
Check for Docker Images (Local Images on Host)
Check for File Permissions Showing Numeric IDs
When the host's user information does not exist inside the container’s
/etc/passwd
file, file permissions will show numeric IDs instead of human-readable names.
Check for Access to Host Network Information
This file contains the routing table of the host system and can provide valuable insights into the host network that may help in lateral movement or further attacks:
Check for Mounted File Systems
Mounting directories or files from the host system into the container exposes host data to the container:
Verify Container Privileges
Look for containers running as root or with
--privileged
mode:
See if it is running as root:
Check the process inside the container:
Test for Namespace Leaks
Check the namespaces that the container uses:
Investigate Container File System for SUID/SGID Binaries
Check for Docker Socket Exposure
Look for Docker Vulnerabilities and Misconfigurations
Investigate the private virtual network
Docker containers typically run in a private virtual network created by Docker, and the default network uses a subnet in the range
172.16.0.0/12
File Ownership Manipulation via Shared Mounts
File Ownership Manipulation via Shared Mounts
Check permissions and ownership when you create a file from host and container:
If the container is miss configured and can creates files as a
root
, and you can access the files created by the host on the container:From the host
, copybash
in to the mounted directory.From the container
, change the ownership and permissions ofbash
toroot
.Execute
bash
asroot
.
Last updated