Skip to Content
Container Security

Container Security

Container security including Docker escape techniques, containerization fundamentals, and hardening best practices for penetration testing and security assessments.

Dec 11, 2025
Updated Nov 22, 2026
3 min read

Overview

Most modern applications ship in containers, and a container is only as isolated as its configuration. On cloud-native and DevOps engagements you will regularly land inside one, and the question becomes whether you can reach the host or the orchestrator from there. These notes cover how the isolation works, how to break out of Docker, and how to lock it down.

Container fundamentals

Container escape

Container hardening

  • Container hardening: configuration for container deployments and orchestration that shuts those escapes down

Attack methodology

Phase 1: enumerate the container

  • Identify the runtime (Docker, Podman, containerd)
  • Check capabilities and the security context
  • Review mounted volumes and host paths
  • Map container networking
  • Check whether the container is privileged
  • Look for access to the Docker socket

Phase 2: find the weakness

  • Misconfigured security settings
  • Privileged mode or dangerous capabilities
  • A mounted Docker socket
  • Secrets in environment variables or files
  • A host kernel version with a known escape exploit
  • Vulnerable packages in the image

Phase 3: exploitation

  • Escape through a privileged container
  • Abuse a mounted Docker socket
  • Exploit dangerous capabilities (CAP_SYS_ADMIN, CAP_SYS_PTRACE)
  • Break namespace isolation
  • Use a kernel exploit if one applies

Phase 4: post-escape

  • Enumerate the host
  • Escalate privileges on the host
  • Access other containers
  • Pivot to the orchestration layer (Kubernetes)
  • Establish persistence

Common container misconfigurations

Dangerous capabilities

  • CAP_SYS_ADMIN: mount operations and namespace manipulation
  • CAP_SYS_PTRACE: debug and inject into processes
  • CAP_SYS_MODULE: load kernel modules
  • CAP_DAC_READ_SEARCH: bypass file read permission checks

Dangerous mounts

  • /var/run/docker.sock: lets you create new containers, including privileged ones
  • /proc: host process information
  • /: the full host filesystem
  • /dev: raw device access

Insecure configurations

  • Privileged mode (--privileged)
  • --pid=host (shares the host PID namespace)
  • --network=host (shares the host network stack)
  • Running as root inside the container
  • Sensitive ports and services exposed

Container security tools

ToolPrimary use
DockerContainer runtime and management
kubectlKubernetes cluster interaction
crictlContainer runtime interface CLI
amicontainedContainer environment enumeration
CDKContainer penetration toolkit

Kubernetes considerations

When the container is a Kubernetes pod:

  • Enumerate service accounts and RBAC permissions
  • Check for a token mounted in /var/run/secrets/kubernetes.io/serviceaccount/
  • Review Pod Security Admission settings and admission controllers (PodSecurityPolicy was removed in Kubernetes 1.25)
  • Test for unauthenticated API access
  • Look for privilege escalation through pod creation
  • Check for an exposed Kubernetes dashboard

On this page