Docker

Docker Privilege Escalation

Docker Shared Directories

Sample Exploitation

  1. Find Files

    $ cd /hostsystem/home/cry0l1t3
    root@container:/hostsystem/home/cry0l1t3$ ls -l
    
    -rw-------  1 cry0l1t3 cry0l1t3  12559 Jun 30 15:09 .bash_history
    -rw-r--r--  1 cry0l1t3 cry0l1t3    220 Jun 30 15:09 .bash_logout
    -rw-r--r--  1 cry0l1t3 cry0l1t3   3771 Jun 30 15:09 .bashrc
    drwxr-x--- 10 cry0l1t3 cry0l1t3   4096 Jun 30 15:09 .ssh
    
    
    
  2. You found ssh key and now you can login

    $ cat .ssh/id_rsa
    
    -----BEGIN RSA PRIVATE KEY-----
    <SNIP>

Docker Sockets

A special file that allows the docker client to communicate with the docker daemon

Sample Exploitation

  1. We found a docker.sock file

  2. Use docker (download from herearrow-up-right) to interact with the socket

  3. Create our own Docker container that maps the host’s root directory (/) to the /hostsystem directory on the container

  4. Login to the new container

Docker Group

Sample Exploitation

  1. We must be in the docker group. (or docker has SUID set or we are included in the sudoers file that can run docker as root)

  2. With this, we can run commands like

  3. Run this command (from gtfobins, use alpine or the image id from step 2)

Docker Socket

This occurs when we are not in root/docker group but docker.sock is writable. The default path for this is /var/run/docker.sock

Last updated