| name | container-technique |
| description | Container methodology: Identifying containerization limits, Docker/K8s misconfigurations, and executing escapes to the host node. |
container-technique
Goal: Exploit container environments (Docker, Kubernetes, LXC) to achieve host-level code execution, horizontal pod movement, or cluster takeover.
When this technique applies
- You have gained a shell via Web RCE or SSH and notice
.dockerenv, kubepods in cgroups, or specific mount patterns.
- You have acquired compromised Kubeconfigs or Service Account tokens.
The Escape Workflow
1. Internal Reconnaissance
Determine the isolation boundaries.
- Am I in a container?:
ls -la /.dockerenv ; cat /proc/1/cgroup
- What privileges do I have?:
capsh --print (look for CAP_SYS_ADMIN, CAP_SYS_MODULE, CAP_SYS_PTRACE).
- Network mapping: Look for
kube-dns or metadata endpoints (e.g. 169.254.169.254 or GCP/Azure equivalents).
2. Hunting for Escape Vectors
3. Kubernetes Specifics
- Service Account Tokens: Located at
/var/run/secrets/kubernetes.io/serviceaccount/.
- API Server Recon: Use
curl -skH "Authorization: Bearer $TOKEN" https://$KUBERNETES_SERVICE_HOST/api/v1/namespaces/default/pods/
- Kubelet / ETCD Unauthenticated Ports: Check if ports
10250 (kubelet), 10255 (kubelet readonly, disabled by default since 1.21 but still common on legacy/GKE), or 2379 (etcd) are exposed internally without authentication. On 10250 the endpoint POST /run/<ns>/<pod>/<container> yields RCE inside any pod.
- RBAC nodes/proxy GET → RCE: A service account with
nodes/proxy GET (frequently granted to monitoring/observability tooling) can proxy the kubelet API and exec into arbitrary pods cluster-wide, including control-plane. Test with kubectl auth can-i get nodes/proxy before deeper enum.
Quality Gates
- Do not break the pod: Kernel module injection and heavy cgroup manipulation can crash the container host. Perform checks first.
- Proof of Action: Once you escape, immediately collect evidence of reaching the underlying host (e.g.,
cat /etc/shadow from the host mount) rather than deploying destructive backdoors.
References
- references/privileged-escapes.md — Load when dealing with a container running with
--privileged or CAP_SYS_ADMIN (mount host disk, cgroups release_agent, core_pattern/modprobe_path).
- references/capability-escapes.md — Load for a single excessive capability without full privileged: capability→vector triage table,
CAP_SYS_MODULE, CAP_DAC_READ_SEARCH/CAP_DAC_OVERRIDE (shocker), CAP_SYS_PTRACE (+--pid=host), CAP_MKNOD.
- references/socket-and-mounts.md — Load when the Docker socket is reachable (CLI or
curl REST API), the user is in the docker group, or sensitive host paths are bind-mounted (-v /:/host, /etc, /root).