Kubernetes pod security escalation review
Brief
Anyone who can start a pod (a running container) in a namespace can run it as any service account there, borrowing that account's rights, and unless the cluster's admission rules refuse it, can mount the disk of the server it runs on or see its processes, which often ends in control of the cluster. Server-side dry runs show what the cluster would accept, and nothing ever runs.
On this page
- Check first
- Where can this identity create pods?
- Which namespaces enforce Pod Security?
- Would admission accept a pod that mounts the node's disk?
- Would it accept a privileged pod that shares the node's processes?
- Can a new pod run as a stronger service account?
- Did the dry runs leave anything behind?
- The defender sees
- Done when
- Not covered
- Tools
- Reviewed
- Situation
- A kubeconfig for an identity that can create pods, such as a CI deployer, on a cluster named in the scope letter, plus read access to namespaces, bindings and pods granted for the review. Every pod test is a server-side dry run: the API server checks and answers, and nothing is stored or scheduled.
- Goal
- A table per namespace: whether it admits a host mount and a privileged pod, and which powerful service accounts a new pod there may run as, each with the dry run's answer.
- Outputs
- Captured on 5 Nov 2026 against a one-node kind cluster in the Atarus Bench review lab, edition
review-lab-0.1: Kubernetes v1.37.0 from a pinned kind node image, its API server on 127.0.0.1, reached with kubectl 1.37.1 on the capture host as aci-deployerservice account. Every pod test was a server-side dry run; no test pod was ever stored or run.
Check first
- The cluster first hour results: who we are, and who holds cluster-admin or an escalation verb.
- Where this identity can create pods, and whether it can create deployments, jobs, cronjobs or daemonsets, since each of those creates pods too.
- The Pod Security labels on each namespace, and any admission webhook such as Kyverno or Gatekeeper that adds its own rules.
- The service accounts in those namespaces and what each is bound to.
- The client's agreement that server-side dry runs are the whole test and no pod runs.
Steps
Where can this identity create pods?
export KUBECONFIG=deployer.kubeconfig
kubectl auth whoami -o jsonpath='{.status.userInfo.username}{"\n"}'
for ns in team-a payments kube-system; do
printf '%-12s %s\n' "$ns" "$(kubectl auth can-i create pods -n "$ns")"
done
Expected output
system:serviceaccount:team-a:ci-deployer
team-a yes # <- two namespaces to test
payments yes
kube-system no
The identity is the CI deployer's service account, and it may create pods in two namespaces. Those two are where the rest of the page runs. The loop names the lab's namespaces; on an engagement run it over every name kubectl get namespaces -o name returns. A deployer that may create deployments or jobs but not pods is tested differently: Pod Security enforces on pods only, so a dry run of a deployment in an enforced namespace is accepted, with a warning only where the namespace also sets the warn label, and the refusal comes later, when the controller creates the pod. For such a deployer, read the namespace labels and any warning, or ask the client to run the pod dry runs with an identity that may create pods. Webhook engines such as Kyverno may refuse the workload object itself.
Negative result. no everywhere: this identity cannot create pods and the page ends here.
Which namespaces enforce Pod Security?
kubectl get namespaces -o custom-columns='NAME:.metadata.name,ENFORCE:.metadata.labels.pod-security\.kubernetes\.io/enforce'
Expected output
NAME ENFORCE
default <none>
kube-node-lease <none>
kube-public <none>
kube-system <none>
local-path-storage <none>
payments baseline # <- refuses host mounts and privileged pods
team-a <none> # <- no label: the cluster's default applies
Pod Security admission reads the enforce label on each namespace. baseline refuses host mounts, host namespaces and privileged containers; restricted adds more. No label means the cluster's default, which is privileged, allowing everything, unless the API server's admission configuration sets another. The label is the expectation; the dry runs below are the proof.
Negative result. Every namespace this identity can create pods in enforces baseline or restricted.
Fix. Label every namespace enforce: baseline at least, restricted where the workloads allow it, and set the cluster-wide default in the admission configuration so a new namespace is not open.
Would admission accept a pod that mounts the node's disk?
The test pod, saved as node-root-test.yaml, mounts the node's whole file system read-only. It is never stored:
apiVersion: v1
kind: Pod
metadata:
name: atarus-node-root-test
spec:
containers:
- name: probe
image: debian:13-slim
command: ["sleep", "60"]
volumeMounts:
- {name: node-root, mountPath: /host, readOnly: true}
volumes:
- name: node-root
hostPath: {path: /}
kubectl apply --dry-run=server -n team-a -f node-root-test.yaml
Expected output
pod/atarus-node-root-test created (server dry run) # <- admitted; nothing stored
kubectl apply --dry-run=server -n payments -f node-root-test.yaml
Expected output
Error from server (Forbidden): error when creating "node-root-test.yaml": pods "atarus-node-root-test" is forbidden: violates PodSecurity "baseline:latest": hostPath volumes (volume "node-root")
A server-side dry run sends the pod through authentication, RBAC and every admission check, then stops before storing it. In team-a the answer is created: a pod with this mount would run. Read-only is no comfort. The node's disk holds the kubelet's credentials and the service account tokens and secrets mounted into every other pod on that node, and on a control-plane node, the cluster's certificate authority key. In payments the baseline policy refuses it by name. The finding is the namespace that admits the mount; we never run the pod to show what it reads.
Negative result. Forbidden in every namespace the identity can create pods in.
Fix. Pod Security baseline or stricter on every namespace that is not a system namespace, and no host mounts outside the few system workloads that need them, each in a namespace no ordinary deployer can create pods in.
Would it accept a privileged pod that shares the node's processes?
kubectl apply --dry-run=server -n team-a -f privileged-test.yaml
Expected output
pod/atarus-privileged-test created (server dry run)
kubectl apply --dry-run=server -n payments -f privileged-test.yaml
Expected output
Error from server (Forbidden): error when creating "privileged-test.yaml": pods "atarus-privileged-test" is forbidden: violates PodSecurity "baseline:latest": host namespaces (hostPID=true), privileged (container "probe" must not set securityContext.privileged=true)
The second test pod, privileged-test.yaml, is the first pod without the host mount, with hostPID: true in the pod spec and securityContext: {privileged: true} on the container. A privileged container has the node's devices and kernel capabilities, and with the host's processes in view it is, for practical purposes, root on the node. team-a admits it and payments refuses it, naming both settings.
Negative result. Forbidden in every namespace, as in payments.
Fix. As above. Workloads that truly need privilege, such as a network or storage driver, belong in their own namespace with its own exemption and no ordinary deployer.
Can a new pod run as a stronger service account?
kubectl get clusterrolebindings \
-o jsonpath='{range .items[*]}{.metadata.name}{" -> "}{.roleRef.name}{" for "}{.subjects[*].name}{"\n"}{end}' \
| grep -E 'cluster-ops|ci-deployer'
Expected output
ci-deployer-review-read -> lab-review-read for ci-deployer
cluster-ops-admin -> cluster-admin for cluster-ops # <- cluster-admin for a subject named cluster-ops; its namespace is not printed
kubectl apply --dry-run=server -n team-a -f service-account-test.yaml
Expected output
pod/atarus-service-account-test created (server dry run) # <- a pod may run as cluster-ops
The grep keeps the lab's two names. On an engagement drop it, print {.subjects[*].kind} and {.subjects[*].namespace} as well, and read kubectl get rolebindings -A the same way, looking for any service account in a namespace this identity can create pods in. In the lab, team-a holds a service account, cluster-ops, bound to cluster-admin. The third test pod names it in serviceAccountName and nothing else, and admission accepts it: a pod may run as any service account in its namespace, so anyone who can create pods in team-a can run code holding cluster-admin's token. Pod Security does not look at the service account at all, so this finding stands even in a restricted namespace.
Negative result. The namespaces where the identity can create pods hold only service accounts with the same or fewer rights than the identity itself.
Fix. Keep powerful service accounts in namespaces where no one else can create pods, set automountServiceAccountToken: false where a workload does not call the API (this limits a compromised workload, not a pod creator, who can set it back to true in the pod spec), and add an admission policy, such as a ValidatingAdmissionPolicy, that limits which service accounts a pod may name.
Did the dry runs leave anything behind?
for ns in team-a payments; do
printf '%-10s %s pods\n' "$ns" "$(kubectl get pods -n "$ns" -o name 2>/dev/null | grep -c .)"
done
Expected output
team-a 0 pods # <- three admitted dry runs, nothing stored
payments 0 pods
A server-side dry run stores nothing, schedules nothing and creates no event, and the count shows it. The lab's namespaces are empty, so the count is 0. On an engagement, take the same count before the first dry run and compare, and look for any name starting atarus-. 2>/dev/null also turns a refusal into 0, so check kubectl auth can-i list pods in each namespace first. This is the line that goes in the statement of changes: no pod was created during the test.
Negative result. The same count as before the first dry run and no pod named atarus- in any tested namespace. A pod named atarus- means a test ran without --dry-run=server: delete it at once and record it in the operator log.
The defender sees
The API server's audit log, where it is on, records each dry run as a pod create by system:serviceaccount:team-a:ci-deployer, with dryRun=All in the request URI and the Pod Security decision in the event's annotations. Denied creates show as 403. At the Request level or above the event carries the pod spec; at Metadata only the verb, user and URI are kept. A rule that alerts on pod creates with host mounts, host namespaces or a privileged container from anyone but the system's own controllers catches the dry runs as well as a real attempt, which is the point: our test should appear there. A one-node kind cluster keeps no audit log unless one is configured, so the lab shows none; if the client's cluster had none either, that goes in the report beside the finding.
Done when
Every namespace the identity can create pods in has its dry runs recorded, the powerful service accounts in those namespaces are named with their bindings, and the pod count shows nothing was stored.
Not covered
Running a pod or reading a node, other routes onto a node such as exec, node proxy and ephemeral containers, admission webhooks beyond Pod Security, and the cloud identity a node or pod holds.