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/dcos_marathon.md
Views: 11789
Vulnerable Application
Utilizing the DCOS Cluster's Marathon UI, 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 owed by root. This exploit abuses this to creates a cron job in the '/etc/cron.d/' path of the host server.
*Notes: The docker image must be a valid docker image from hub.docker.com. Further more the docker container will only deploy if there are resources available in the DC/OS
DCOS
This Exploit was tested with CentOS 7 as the host operating system for the 2 services of the DCOS cluster. With DCOS version 1.7 and 1.8, with Default 'custom' installation for on site premise setup. Only the Install part of the DCOS guide was completed, the system hardening and securing your cluster section where skipped. This is to represent a 'Default' install with a system admin conducting hasty deployments taking no thought about security.
To Setup Your Cluster
I recommend doing a 'on-premise'/custom cluster. https://dcos.io/docs/1.8/administration/installing/custom/ Create a virtual CentOS machine, install requirements base on the above guide.
Install a supported version of docker on the CentOS systems https://dcos.io/docs/1.8/administration/installing/custom/system-requirements/install-docker-centos/
Once the CentOS machine has rebooted, edit the systemctl service file for docker and change the ExecStart- line to ExecStart=/usr/bin/docker daemon --storage-driver=overlay -H fd://
restart the docker service and verify it is running. lastly generate ssh rsa keys for authentication. And update the /etc/ssh/sshd_config file to support root login.
Shut down the CentOS vm, take a snapshot. (This will be your base) clone the VM 2 times. One will be DCOS-Master, the Other DCOS-Agent. Start the DCOS-Master and DCOS-Agent virtual machines You just cloned. Login and get their current IP address.
Note: I recommend giving them static IPs if you have further use for the cluster.
From here use another Linux machine with docker installed to finish the installation process. I used an Ubuntu machine with docker installed.
Follow the custom CLI guide for creating the required files in the genconf folder. https://dcos.io/docs/1.8/administration/installing/custom/cli/
Example genconf/config.yaml
Example genconf/ip-detect
place your id_rsa ssh key into the genconf file and rename the file to ssh_key and chmod 0600 genconf/ssh_key
Deploying the cluster in the folder containing the genconf folder do the following. NOTE: if following the cli install from DCOS itself, it will fail if you do --install-prereqs. It will install an unsupported version of docker.
If all is passing navigate to http://[master_ip]:8080/ You should see the Marathon UI web application.
Exploitation
This module is designed for the attacker to leverage, creation of a docker container with out authentication through the DCOS Marathon UI to gain root access to the hosting server of the docker container in the DCOS cluster.
Options
DOCKERIMAGE is the hub.docker.com docker container image you are wanting to have the DCOS Cluster to deploy for this exploit.
TARGETURI this is the path to make the Marathon UI web request to. By default this is /v2/apps
WAIT_TIMEOUT is how long you will wait for a docker container to deploy before bailing out if it does not start.
CONTAINER_ID is optional if you want to have your container docker have a human readable name else it will be randomly generated
Steps to exploit with module
Start msfconsole
use exploit/linux/http/dcos_marathon
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 agent server