Kubernetes Security
From a compromised pod to cluster control, and how to stop it
Kubernetes runs containers across a cluster and is controlled through its API server. If an attacker compromises one application container, the next question is what that pod can reach: other services, cloud metadata, or the API server with a powerful service account. Good defaults contain the damage.
Advanced · 5 steps
| Control plane | API server, controlled by RBAC |
|---|---|
| Pod identity | Service account token |
| Isolation | Network policies, namespaces |
| Workload rules | Pod Security Standards (restricted) |
| Escape technique | T1611 (Escape to Host) |
| Benchmark | CIS Kubernetes Benchmark |
Step by step
Foothold in a pod One vulnerable app container
An attacker exploits a bug in the web app and can run commands inside its container. They look around: environment variables, mounted files, and the service account token Kubernetes mounts into pods by default.
Ask the API server What can this service account do?
With the token, the attacker queries the API server. In a well-configured cluster, the web app's service account has no permissions at all, and every request is denied. In a poorly configured one, it might be able to list secrets or create pods.
Move sideways Network policies
Next the attacker tries to reach the payments database directly. Without network policies, every pod can talk to every other pod. Here a default-deny policy only lets the payments API reach the database, so the connection is dropped.
Try to escape Privileged containers and host mounts
If the pod ran as privileged or mounted the host filesystem, the attacker could break out to the worker node and every pod on it. The "restricted" Pod Security Standard blocks those settings, so this pod runs as non-root with no extra capabilities.
Layered defaults Each layer limits the blast radius
Because the token wasn't useful, network policies blocked lateral movement and the pod couldn't escape, the compromise stayed inside one container. Runtime detection alerted on the unusual shell, and the pod was replaced from a clean image while the app bug was fixed.
Best practices
- Don't mount service account tokens into pods that don't need the API
- Grant RBAC per namespace and per verb; avoid cluster-admin for workloads
- Default-deny network policies, then allow only needed traffic
- Enforce the "restricted" Pod Security Standard: no privileged pods, no host mounts, non-root
- Block pod access to the cloud metadata service and scan images before deploy
More in Cloud Security.
Packets
| No. | Time | Source | Destination | Protocol | Info | Size |
|---|