Down by the Docker

NotSoSecure Webinar on Docker Vulnerability

22 August 2017

Webinar Details

We at NotSoSecure did a 60 minutes webinar with 3 topics of 20 minutes each. One of them was “Down by the Docker”

Abstract

Docker is the new kool kid in town. This presentation covers some of the common goof-ups and what should be kept in mind when dealing with docker configurations.

Vulnerable VM

Download the Vulnerable Docker VM : https://www.notsosecure.com/vulnerable-docker-vm/

Event details

/slides/2017-down-by-the-docker/

AI Generated Summary

AI Generated Content Disclaimer

Note: This summary is AI-generated and may contain inaccuracies, errors, or omissions. If you spot any issues, please contact the site owner for corrections. Errors or omissions are unintended.

Delivered as a NotSoSecure webinar in 2017, “Down by the Docker” is a security-focused overview of Docker presented from a penetration tester’s perspective. The talk covers how Docker environments differ from traditional infrastructure during assessments, demonstrates three critical Docker misconfigurations that lead to host compromise, and outlines best practices for securing Docker deployments along with tools for configuration review and vulnerability scanning.

Summary

The deck opens with why Docker won adoption: it gets rid of the “It works on my System” syndrome, makes environments and test beds easy and quick to set up, is loved by startups and PoC development teams, and is loved by Google and similar companies for scalability and deployment ease. The security verdict is stated plainly: Docker is as secure as you configure it, which frames the rest of the talk.

The pentester’s perspective section explains what changes when the target runs in containers. From the outside everything looks the same, but indicators reveal a containerized environment: /proc/1/cgroup will show docker references, and pid 1 is not init or launchd. Operational differences follow: bash, Python, and Perl aren’t usually available in minimal containers; containers are disposable so no persistence is ensured; containers can have different resources shared; a container crash means a new spawn anywhere; and Docker uses its internal network (172.17.0.0/16), with Docker’s networking documentation and a Vimeo video as references.

Three misconfigurations form the demo core. First, running container processes as root: by default the host UID equals the container UID, so root in container equals root on the base box, and if a filesystem or part of it is shared, an attacker has a direct path to write privileged files and get root, demonstrated with docker run -itv /:/host alpine /bin/sh. Second, exposing the docker socket or TCP port: the Docker socket equals access to the docker daemon, Docker can listen on port 2375 (noauth) or 2376 (tls), the exposure generally appears in dashboard or reporting application containers, and any misconfiguration or unintended exposure means host compromise. Third, unpatched host or guest: Docker shares the kernel with the host, so kernel bugs result in host compromise, while an unpatched guest results in guest compromise, with a second Vimeo demo video referenced.

The defensive section presents security as secure configuration at all levels: scrutinize the “docker” group (membership effectively grants root-equivalent access), keep the Docker socket available only to root and docker group users, keep the Docker daemon restricted to root and docker group users, run container processes via limited users, and keep both Docker host and guests up-to-date, plus regular scanning of Docker configuration files.

Tooling for Docker configuration review and vulnerability scanning rounds out the deck: Docker Security Scanning via DockerHub, Clair (github.com/coreos/clair, CoreOS’s open source scanner), Atomic Scan (Red Hat’s container vulnerability detection), Anchore (anchore.com, analysis and policy enforcement), Dockerscan (github.com/cr0hn/dockerscan), Dockscan (github.com/kost/dockscan), and Nessus (Tenable’s Docker auditing, as described in their blog post on auditing Docker with Nessus 6.6). The session closes by pointing to NotSoSecure’s deliberately vulnerable Docker VM, created to suffer from many of the vulnerabilities discussed, available for download at notsosecure.com/vulnerable-docker-vm/ for hands-on practice.

Key Themes

Notable Points

  1. Takeaway: never run container processes as root; specify a non-root USER in Dockerfiles and verify that production containers are not running with UID 0, since root inside a container equals root on the host when filesystems are shared.
  2. Takeaway: audit Docker socket and daemon exposure in your infrastructure: ensure /var/run/docker.sock is not mounted into application containers unless absolutely necessary, and never expose the Docker TCP port (2375/2376) without proper authentication and network restrictions.
  3. Takeaway: implement regular patching for both the Docker host kernel and all container base images, since Docker’s shared-kernel architecture means a single kernel vulnerability compromises all containers on the host.
  4. Takeaway: integrate container image scanning into your CI/CD pipeline using tools like Clair, Anchore, or Docker Security Scanning to catch known vulnerabilities before deployment.
  5. Takeaway: restrict Docker group membership as carefully as you would restrict root access; any user in the Docker group can effectively gain root on the host through container creation.
  6. Takeaway: practice Docker security assessment techniques using the NotSoSecure vulnerable Docker VM to build familiarity with identifying and exploiting these common misconfigurations in a safe environment.
  7. Takeaway: during penetration tests, check /proc/1/cgroup and PID 1 to identify containerized environments, then look for mounted host filesystems, exposed Docker sockets, and kernel vulnerabilities as escalation paths.
  8. The host-compromise demo command shown on the slide is docker run -itv /:/host alpine /bin/sh, mounting the host root filesystem into the container.
  9. Docker daemon exposure paths named on the slides: the socket at /var/run/docker.sock and TCP ports 2375 (noauth) and 2376 (tls), commonly exposed by dashboard or reporting application containers.
  10. Container detection indicators: /proc/1/cgroup containing docker references and pid 1 differing from init or launchd; the Docker internal network sits in 172.17.0.0/16.
  11. Tool references cited by URL: github.com/coreos/clair, developers.redhat.com (Atomic Scan announcement), anchore.com, github.com/cr0hn/dockerscan, github.com/kost/dockscan, and Tenable’s blog on auditing Docker with Nessus, plus demo videos at vimeo.com/219495998 and vimeo.com/218622598.

Notable Quotes

“Allows to get rid of β€œIt works on my System” syndrome”

“Secure: as secure as you configure it.”

“Root in container == root on base box.”

“If a file system or part of it is shared, you have direct path to write privileges files and get root”

“Docker shares kernel with the host”

“We have created a vulnerable docker VM that suffers from many of the vulnerabilities discussed throughout this session.”

Social chatter