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 Dec 11, 2025
2 min read

Overview

Containers have revolutionized application deployment, but they also introduce unique security challenges. Understanding container security is essential for modern penetration testing, especially in cloud-native and DevOps environments. This section covers container fundamentals, escape techniques, and hardening strategies.

Container Fundamentals

Container Escape Techniques

Container Hardening

Attack Methodology

Phase 1: Container Enumeration

  • Identify container runtime (Docker, Podman, containerd)
  • Check container capabilities and security context
  • Review mounted volumes and host paths
  • Enumerate container networking
  • Check for privileged containers
  • Review Docker socket access

Phase 2: Vulnerability Discovery

  • Identify misconfigured security settings
  • Check for privileged mode or dangerous capabilities
  • Look for mounted Docker socket
  • Review exposed secrets and environment variables
  • Check kernel version for container escape exploits
  • Analyze container image for vulnerabilities

Phase 3: Exploitation

  • Leverage privileged containers for escape
  • Abuse mounted Docker socket
  • Exploit dangerous capabilities (CAP_SYS_ADMIN, CAP_SYS_PTRACE)
  • Break namespace isolation
  • Use kernel exploits if applicable

Phase 4: Post-Escape

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

Common Container Misconfigurations

Dangerous Capabilities

  • CAP_SYS_ADMIN - Allows mount operations and namespace manipulation
  • CAP_SYS_PTRACE - Process debugging and injection
  • CAP_SYS_MODULE - Load kernel modules
  • CAP_DAC_READ_SEARCH - Bypass file permission checks

Dangerous Mounts

  • /var/run/docker.sock - Docker socket access enables container creation
  • /proc - Host process information
  • / - Full host filesystem access
  • /dev - Device access for low-level operations

Insecure Configurations

  • Running containers in privileged mode (--privileged)
  • Using --pid=host (share host PID namespace)
  • Using --network=host (share host network)
  • Running as root user inside container
  • Exposing sensitive ports and services

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 attacking Kubernetes environments:

  • Enumerate service accounts and RBAC permissions
  • Check for token mounted in /var/run/secrets/kubernetes.io/serviceaccount/
  • Review pod security policies and admission controllers
  • Test for unauthorized API access
  • Look for privilege escalation through pods
  • Check for exposed Kubernetes dashboard

Last updated on

Container Security | Drake Axelrod