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
- Docker overview and appeal: Docker eliminates the “it works on my system” problem, provides quick and easy environment setup, and is widely adopted by startups for PoC development and by large organizations like Google for scalability and deployment ease. Critically, Docker is “as secure as you configure it”: security is not automatic.
- How Docker differs for penetration testers: From the outside, a Docker-hosted application looks the same as any other. Key indicators that you’re inside a container include /proc/1/cgroup showing Docker references and PID 1 not being init or launchd. Significant operational differences include bash, Python, and Perl often unavailable in minimal containers; containers being disposable so persistence is not guaranteed; container crashes leading to new spawns potentially on different hosts; and Docker’s internal network (typically 172.17.0.0/16).
- Docker goof-up #1, running container processes as root: The host UID maps directly to the container UID by default, meaning root inside the container equals root on the host. If any portion of the host filesystem is shared with the container, an attacker with root inside the container can directly write privileged files and escalate to host root. The demo shows docker run -itv /:/host alpine /bin/sh as a direct path to host compromise.
- Docker goof-up #2, exposing Docker socket or TCP port: The Docker socket (/var/run/docker.sock) provides direct access to the Docker daemon. Docker can also listen on port 2375 (unauthenticated) or 2376 (TLS). This exposure commonly occurs in dashboard or reporting application containers. Any misconfiguration or unintended exposure of the socket or TCP port equals complete host compromise, as it allows an attacker to create arbitrary containers with host filesystem access.
- Docker goof-up #3, unpatched host or guest: Docker shares the kernel with the host, so kernel vulnerabilities directly lead to host compromise from within a container. Similarly, unpatched guest images contain vulnerabilities that can be exploited to compromise the container itself. Keeping both the host OS and container images updated is essential.
- Secure Docker configuration best practices: Scrutinize membership of the “docker” group, which effectively grants root-equivalent access; restrict Docker socket access to root and docker group users only; restrict Docker daemon access to root and docker group users only; run container processes via limited (non-root) users; keep both Docker host and guest images up-to-date; and regularly scan Docker configuration files for misconfigurations.
- Docker configuration review and scanning tools: Docker Security Scanning (built-in via DockerHub), Clair (CoreOS open source vulnerability scanner for container images, github.com/coreos/clair), Atomic Scan (Red Hat’s container vulnerability detection tool), Anchore (container analysis and policy enforcement platform, anchore.com), Dockerscan (github.com/cr0hn/dockerscan), Dockscan (Docker installation security scanner, github.com/kost/dockscan), and Nessus (Tenable’s Docker auditing capabilities).
- Vulnerable Docker VM: NotSoSecure released a deliberately vulnerable Docker VM incorporating the misconfigurations discussed in the presentation, available at notsosecure.com/vulnerable-docker-vm/ for hands-on practice.
Notable Points
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.”