December 4, 2026
The Container Is Not a Sandbox: How One Misconfigured Pod Becomes Cluster Admin
Containers are Linux processes with good manners. Kubernetes misconfigurations take the manners away, and attackers know the list by heart.

By Fateyaly
7 min read
In 2018, researchers at RedLock found that Tesla's Kubernetes cluster had an administration console exposed to the internet with no password. Attackers had already been inside. They had deployed cryptomining pods and kept CPU usage low and traffic behind a CDN to avoid detection. The cluster's pods also had access to cloud credentials for an S3 bucket holding telemetry data.
That incident shows the pattern in miniature: one exposed component, one over-trusted workload, and credentials within reach. This article explains why containers don't isolate as much as people assume, then walks through the attack path from "code execution in one pod" to "owns the cluster", with the specific settings that break each step.
What a container actually is
A container is an ordinary Linux process with restrictions applied by the kernel:
- Namespaces limit what it can see (process IDs, network, mounts, hostname, users).
- cgroups limit what it can use (CPU, memory).
- Capabilities, seccomp, and LSMs (AppArmor, SELinux) limit what it can do.
There is no hypervisor. Every container on a node shares one kernel. If you can escape the restrictions, you are a process on the host. That also means a kernel vulnerability is a vulnerability in every container on the machine, which is why the isolation story is fundamentally weaker than a VM.
You can see how thin the boundary is from inside one:
# Inside a container: what can I do?
cat /proc/self/status | grep Cap # capability bitmasks
capsh --decode=00000000a80425fb # decode them (hex value from above)
mount | grep -E "docker.sock|/host" # anything interesting mounted?
ls -l /var/run/secrets/kubernetes.io/serviceaccount/ # a cluster credential, if present# Inside a container: what can I do?
cat /proc/self/status | grep Cap # capability bitmasks
capsh --decode=00000000a80425fb # decode them (hex value from above)
mount | grep -E "docker.sock|/host" # anything interesting mounted?
ls -l /var/run/secrets/kubernetes.io/serviceaccount/ # a cluster credential, if presentThe attack path
Attackers rarely need a fancy exploit. They chain configuration weaknesses. A typical path looks like this:
- Initial foothold in one pod: an app vulnerability (RCE, SSRF, a malicious dependency), a leaked kubeconfig, or an exposed management interface.
- Discovery from inside: read the service account token, query the API server, and check what this identity can do.
- Privilege escalation through the pod's own settings, its RBAC permissions, or a kernel/runtime bug.
- Node compromise: escape to the host.
- Lateral movement: from the node, read every other pod's secrets and tokens on it, and reach the cloud metadata service for node-level cloud credentials.
- Cluster takeover: find a token with cluster-admin rights, or reach etcd.
Each step has well-known preventions.
Misconfiguration 1: Privileged containers and dangerous mounts
privileged: true gives the container nearly all capabilities, access to host devices, and relaxed seccomp/AppArmor. From there, escaping is routine:
# In a privileged container: mount the host's disk and chroot into it
mkdir /mnt/host && mount /dev/sda1 /mnt/host
chroot /mnt/host# In a privileged container: mount the host's disk and chroot into it
mkdir /mnt/host && mount /dev/sda1 /mnt/host
chroot /mnt/hostOther settings that are equally dangerous, even without privileged:
hostPathmounts of /,/etc,/var/lib/kubelet, or/var/run.- Mounting the container runtime socket (
/var/run/docker.sockor the containerd socket). Whoever can talk to that socket can start a new privileged container on the host. This is "root on the node" in one API call, and it's commonly added to CI pods for building images. hostPID: true, which lets the container see and signal host processes (and read their environment via/proc), andhostNetwork: true, which puts it on the node's network, bypassing network policy and reaching node-local services.CAP_SYS_ADMIN, a broad capability that enables many escape techniques.
Misconfiguration 2: Running as root, with a writable filesystem
Root inside a container is root-ish against the shared kernel. Combined with any escape bug, it matters a great deal. Writable root filesystems let an attacker drop tools and persist.
What a hardened pod looks like
apiVersion: v1
kind: Pod
metadata:
name: web
spec:
automountServiceAccountToken: false # no cluster credential unless needed
securityContext:
runAsNonRoot: true
runAsUser: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: app
image: registry.example.com/web@sha256:<digest> # pin by digest
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
resources:
limits: { cpu: "500m", memory: "256Mi" }apiVersion: v1
kind: Pod
metadata:
name: web
spec:
automountServiceAccountToken: false # no cluster credential unless needed
securityContext:
runAsNonRoot: true
runAsUser: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: app
image: registry.example.com/web@sha256:<digest> # pin by digest
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
resources:
limits: { cpu: "500m", memory: "256Mi" }Each line closes a specific route: no token to steal, no root, no setuid escalation, no write access to the filesystem, no capabilities, and the default seccomp profile blocking risky syscalls. This should be the baseline manifest, and exceptions should be justified.
Enforce it: Pod Security Admission
Writing a good manifest is not the same as ensuring that every manifest is good. Kubernetes has Pod Security Standards with three levels (privileged, baseline, restricted) enforced by the built-in Pod Security Admission controller, which replaced PodSecurityPolicy (removed in 1.25). Apply it per namespace with labels:
kubectl label namespace prod \
pod-security.kubernetes.io/enforce=restricted \
pod-security.kubernetes.io/warn=restricted \
pod-security.kubernetes.io/audit=restrictedkubectl label namespace prod \
pod-security.kubernetes.io/enforce=restricted \
pod-security.kubernetes.io/warn=restricted \
pod-security.kubernetes.io/audit=restrictedStart with warn and audit to see what would break before you turn on enforce. For rules beyond the built-in standards, such as image registry allowlists, required labels, or banning hostPath, use a policy engine like Kyverno, OPA Gatekeeper, or the built-in ValidatingAdmissionPolicy.
Misconfiguration 3: RBAC that says yes to everything
A foothold is only as dangerous as the identity it inherits. Every pod gets a service account, and by default its token is mounted at a known path, so anyone with code execution can read it and call the API server:
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
curl -sk -H "Authorization: Bearer $TOKEN" \
https://kubernetes.default.svc/api/v1/namespaces/default/secretsTOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
curl -sk -H "Authorization: Bearer $TOKEN" \
https://kubernetes.default.svc/api/v1/namespaces/default/secretsWhether this returns secrets or 403 Forbidden is entirely an RBAC question. Common mistakes:
- Binding
cluster-adminto a service account because "it's easier." - Wildcards:
verbs: ["*"],resources: ["*"]. - Granting
get/liston secrets cluster-wide. Listing secrets means reading all of them. createon pods in a namespace. A user who can create pods can usually escalate, because they can create a pod that mounts any service account or secret in that namespace, or a privileged one if nothing blocks it.- Permissions like
escalate,bind, orimpersonate, which let a subject grant itself more.
Audit with the tools Kubernetes gives you:
# What can this service account do?
kubectl auth can-i --list --as=system:serviceaccount:prod:web
# Who can read secrets cluster-wide?
kubectl auth can-i get secrets --all-namespaces --as=system:serviceaccount:prod:web# What can this service account do?
kubectl auth can-i --list --as=system:serviceaccount:prod:web
# Who can read secrets cluster-wide?
kubectl auth can-i get secrets --all-namespaces --as=system:serviceaccount:prod:webOpen-source tools such as rbac-police, kubescape, and KubiScan can scan for risky bindings at scale. In practice: one service account per workload, namespace-scoped Roles rather than ClusterRoles, automountServiceAccountToken: false by default, and short-lived bound tokens (the default in current Kubernetes versions).
Misconfiguration 4: Exposed control-plane components
The Tesla-style failure, and still common in internet scans:
- Kubernetes dashboard with no authentication or a broad service account.
- kubelet API (port 10250) with anonymous authentication enabled, allowing command execution in pods. Set
--anonymous-auth=falseand use webhook authorization. - etcd reachable without client certificate authentication. etcd holds the cluster's entire state, including every Secret. Require mTLS, restrict the network, and enable encryption at rest for Secrets (remember that by default they're only base64-encoded, not encrypted).
- The API server itself exposed publicly without restrictions. Limit it with allowlisted source ranges or a private endpoint.
- Add-ons. In March 2025, researchers disclosed "IngressNightmare," a set of vulnerabilities in the ingress-nginx controller. The worst one let an attacker with network access to the admission webhook achieve code execution in the controller, which commonly had access to secrets across the cluster. Admission webhooks and controllers that run with broad permissions are high-value targets, so treat them like it: patch quickly and never expose them.
Misconfiguration 5: A flat network
By default, any pod can talk to any other pod, and often to the node and the cloud metadata service. An SSRF bug in your frontend can then reach your database, the internal admin UI, or 169.254.169.254 (see the Capital One article for how that ends).
Start with default-deny, then open only what's needed:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: prod
spec:
podSelector: {}
policyTypes: ["Ingress", "Egress"]apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: prod
spec:
podSelector: {}
policyTypes: ["Ingress", "Egress"]NetworkPolicy objects only take effect if your CNI plugin enforces them (Calico and Cilium do). On cloud platforms, also block pods from the metadata endpoint or restrict it: enforce IMDSv2 with a hop limit of 1 on AWS nodes, and use the platform's workload-identity feature (IRSA or EKS Pod Identity, GKE Workload Identity, Azure Workload Identity) so each pod gets narrowly scoped cloud credentials instead of inheriting the node's.
Real escapes: when the runtime or kernel is the bug
Hardening settings reduce the attack surface, but shared-kernel isolation has failed in the real world:
- CVE-2019โ5736 (runc): a malicious container could overwrite the host's
runcbinary and gain root on the host, triggered when someone ran a command inside the container. - CVE-2022โ0847 ("Dirty Pipe"): a Linux kernel bug allowing writes to read-only files, which is exploitable from inside containers because they share the kernel.
- CVE-2024โ21626 ("Leaky Vessels"): a runc flaw where a leaked file descriptor and working-directory handling let a malicious image or build step reach the host filesystem.
The general lessons: patch the node OS, kernel, and container runtime on a schedule, don't run untrusted images with weak settings, and for genuinely untrusted workloads (multi-tenant platforms, code-execution services), add a stronger boundary: sandboxed runtimes like gVisor or Kata Containers, or microVMs such as Firecracker. Newer Kubernetes releases also support user namespaces for pods (hostUsers: false), which maps container root to an unprivileged user on the host. Check the feature's status in your version before relying on it.
Supply chain, again
Everything above assumes the image is yours. Images pulled from public registries, base images that haven't been rebuilt in two years, and CI jobs with privileged access are the same problem from the previous article. Scan images (Trivy, Grype), use minimal or distroless bases to shrink the attacker's toolbox, pin by digest, sign and verify images (Sigstore cosign, with an admission policy that rejects unsigned ones), and keep an SBOM.
Detect what you can't prevent
Prevention fails, so watch for behavior that has no business appearing in your workloads:
- Falco (or similar eBPF-based runtime tools such as Tetragon and Tracee) can alert on a shell spawning in a container, reads of
/etc/shadow, writes below/bin, unexpected outbound connections, or a process touching the container runtime socket. - Kubernetes audit logs: ship them off-cluster and alert on
execinto pods, creation of privileged pods, changes to ClusterRoleBindings, and secret reads by unusual identities. - Cloud audit logs, correlated with the above. Credentials issued to a node being used from elsewhere is a strong signal.
A checklist for this week
# Run a benchmark against your cluster
kube-bench # CIS Kubernetes Benchmark checks
kubescape scan # misconfig and RBAC scan against frameworks
# Find privileged or host-sharing pods
kubectl get pods -A -o json | jq -r '
.items[] | select(
.spec.hostNetwork==true or .spec.hostPID==true or
(.spec.containers[]?.securityContext.privileged==true)
) | "\(.metadata.namespace)/\(.metadata.name)"'
# Find cluster-admin bindings
kubectl get clusterrolebindings -o json | jq -r '
.items[] | select(.roleRef.name=="cluster-admin") |
"\(.metadata.name): \([.subjects[]? | "\(.kind)/\(.name)"] | join(", "))"'# Run a benchmark against your cluster
kube-bench # CIS Kubernetes Benchmark checks
kubescape scan # misconfig and RBAC scan against frameworks
# Find privileged or host-sharing pods
kubectl get pods -A -o json | jq -r '
.items[] | select(
.spec.hostNetwork==true or .spec.hostPID==true or
(.spec.containers[]?.securityContext.privileged==true)
) | "\(.metadata.namespace)/\(.metadata.name)"'
# Find cluster-admin bindings
kubectl get clusterrolebindings -o json | jq -r '
.items[] | select(.roleRef.name=="cluster-admin") |
"\(.metadata.name): \([.subjects[]? | "\(.kind)/\(.name)"] | join(", "))"'Then:
- Turn on Pod Security Admission in
warnmode for every namespace. - Set
automountServiceAccountToken: falseunless a pod calls the API. - Search for
docker.sockandhostPathin your manifests and CI templates. - Apply a default-deny NetworkPolicy in one namespace and fix what breaks.
- Confirm the kubelet, etcd, dashboard, and API server aren't reachable from the internet.
- Check that the node OS, kernel, and runtime are on a patch schedule.
- Turn on audit logging, and send it somewhere an attacker in the cluster can't edit.
The takeaway
The most common route to cluster takeover is a chain of small, individually "reasonable" defaults: a token mounted automatically, a pod allowed to run as root, a role granted broadly, a network with no walls. Each link looks harmless until someone connects them. Break any of them and the attacker's path gets harder; break several and a compromised pod stays a compromised pod. Treat containers as a convenience for packaging and a modest layer of isolation, never as a security boundary you can lean your whole weight on.