Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/documentation/modules/exploit/linux/http/docker_daemon_tcp.md
Views: 11789
Vulnerable Application
Utilizing Docker via unprotected tcp socket (2375/tcp, maybe 2376/tcp with tls but without tls-auth), an attacker can create a Docker container with the '/' path mounted with read/write permissions on the host server that is running the Docker container. As the Docker container executes command as uid 0 it is honored by the host operating system allowing the attacker to edit/create files owned by root. This exploit abuses this to creates a cron job in the '/etc/cron.d/' path of the host server.
The Docker image should exist on the target system or be a valid image from hub.docker.com.
Docker Engine
By default, Docker runs via a non-networked unix socket. It can also optionally communicate using a tcp socket.
Warning: Changing the default docker daemon binding to a TCP port or Unix docker user group will increase your security risks by allowing non-root users to gain root access on the host. Make sure you control access to docker. If you are binding to a TCP port, anyone with access to that port has full Docker access; so it is not advisable on an open network. -- from docs.docker.com
This module was tested with Debian 9 and CentOS 7 as the host operating system and with Docker CE 17.06.0-ce and Docker Engine 1.13.1.
Install Debian 9
First install Debian 9 with default task selection. This includes the "standard system utilities".
Install Docker
Then install a supported version of Docker on Debian system.
Activate unprotected tcp socket
Once Docker is installed, customize the Docker daemon options and add the tcp socket -H tcp://0.0.0.0:2375
option. On Debian override the settings from /lib/systemd/system/docker.service
with a new file /etc/systemd/system/docker.service
.
Further information: docker systemd and docker daemon options.
Mitigation
Disable or protect the Docker tcp socket.
User namespaces did not protect against this.
Exploitation
This module is designed for the attacker to leverage, creation of a Docker container with out authentication through the Docker tcp socket to gain root access to the hosting server of the Docker container.
Options
DOCKERIMAGE is the locally or from hub.docker.com available image you are wanting to have Docker to deploy for this exploit.
CONTAINER_ID if you want to have a human readable name for your container, else it will be randomly generated
Steps to exploit with module
Start msfconsole
use exploit/linux/http/docker_daemon_tcp
Set the options appropriately and set VERBOSE to true
Verify it creates a Docker container and it successfully runs
After a minute a session should be opened from the Docker server