What is the Docker security risk of /var/run/docker.sock?

后端 未结 4 847
温柔的废话
温柔的废话 2020-12-31 19:01

In this blog article, I found the quote below in a comment:

Ben Firshman

Yes – you\'re right I should have pointed out the security issue

4条回答
  •  鱼传尺愫
    2020-12-31 19:12

    The accepted answer supplied a great explanation, so I won't repeat any of the details regarding the fact that you're mounting a file owned by root.

    Maybe the following example is trivial to some readers, but I'm surprised nobody mentioned it.

    Remember the fact that you have access to a very special file on the host - docker.sock.

    So if you install Docker inside your container:

    apt-get update  
    apt-get install docker.io -y
    

    Or as a one-liner with the container creation:

    docker run -it -v /var/run/docker.sock:/var/run/docker.sock ubuntu:latest sh -c  "apt-get update ; apt-get install docker.io -y ; bash"
    

    (Inside the container check with docker ps that you see the other containers running on the host).

    Now you have full control over the other containers in your host.

提交回复
热议问题