docker container escape
Last updated
Was this helpful?
Last updated
Was this helpful?
Docker is an open-source containerization platform used for developing, deploying, and managing applications in lightweight virtualized environments called containers.
List running processes
Look for docker.env file
Those pesky cgroups
Navigating to “/proc/1” and then catting the “cgroups” file (cat cgroup).
Use following code to Verify you are in Docker
Run the following cmd
If we’re in bash
If we’re in alpine
You can see the images repo
By using ps aux you can view the process with processID see pid 1 is running root it is the first one that executed when the system is booted.
Exploiting it with nsenter
list out all the capabilities
On attacker VM:
First make a shell.sh and set python server and set listner.
On target machine:
STEP1: Listing the images of the container of the host
STEP2: Now generate id_rsa in your machine
STEP3: Creating a new docker container with image ID
Now you’ll see you created a docker and get the id. eg: {“Id”:”c19a25c6cc7245030bf9741d300f632cc7f1e5f12adad238edce23d387ba00c2”,”Warnings”:[]}
STEP4: Now we gonna use the id and start the docker
STEP5: Login SSH via your private key as user root and now you’re root
If we can find any writable backup scripts in a docker instance then we can add our own reverse shell into it.
Run a netcat listener
Check /var/run dir for docker.sock file, if it’s there and you’re root then you can exploit it. First see that you can use curl cmd, if not then wget static curl from your system for static curl see the arch of target machine and get the static curl from