BERRY9 IT SERVICES

Docker Container Security Testing: Capabilities & Escapes

How penetration testers test Docker and container runtime security: --privileged flags, mounted docker.sock, dangerous Linux capabilities, and root users.

DevSecOps · By Thimmagurudu Bathini, CTO · Published · 5 min read

Docker Container Security Testing: Capabilities & Escapes architecture and testing overview

What Happens When RCE Meets a Weak Container

Containers are not full virtual machines—if a containerized web app suffers an RCE or command injection, weak container runtime flags decide whether the attacker stays trapped or escapes to the underlying host node. Testing container hardening closes that escalation bridge.

securityContext:
  runAsNonRoot: true
  readOnlyRootFilesystem: true
  allowPrivilegeEscalation: false
  capabilities:
    drop: ["ALL"]

Four Runtime Flags That Enable Host Escape

High-risk Docker & container runtime configurations
Runtime SettingEscape / Escalation RiskSecure Baseline
--privileged: trueDisables isolation and exposes host devices for trivial escapeNever use --privileged in app workloads
/var/run/docker.sock MountedContainer can spin up a root host-mounted container immediatelyRemove Docker socket mounts; use rootless/Kaniko builders
CAP_SYS_ADMIN / CAP_NET_RAWAllows mount tricks, cgroup escapes, or ARP/DNS spoofingDrop ALL capabilities and add back only minimal required caps
UID 0 (Root) + Writable FSApp runs as root and can modify binaries or persistSet non-root USER, readOnlyRootFilesystem: true, no-new-privileges

Auditing Capabilities, Root UIDs & Pod Specs

  • Inspect Docker Compose, ECS task definitions, and Kubernetes PodSecurity specs for privileged mode and hostPath mounts.
  • Check whether containers run as UID 0 or retain CAP_SYS_ADMIN / CAP_SYS_PTRACE.
  • Verify container images for minimal base OS (distroless/alpine) and patched OS packages.
  • Test egress network policies from inside running pods to confirm metadata and internal control planes are blocked.

Enforcing Non-Root & Read-Only RootFS

Run containers as non-root with read-only root filesystems, drop all Linux capabilities, and never mount /var/run/docker.sock inside application containers.

Test your container runtime and Kubernetes workloads from ₹36,000 + 18% GST. Request a scoped proposal →

Container Security Testing Questions

Does a container vulnerability scan catch runtime escape paths?

Image scanners only list CVEs in packages; they miss runtime flags like privileged: true, hostPath mounts, and RBAC escapes.

Can BERRY9 test both containers and Kubernetes clusters?

Yes—under our DevSecOps and infrastructure security services starting from ₹36,000 + 18% GST.