Pod Security Admission in production
How to turn on Pod Security Admission on a working namespace: warn and audit, fixing templates, enforce with a pinned version, and the trap of a Deployment without Pods.
The third lesson of the hardening track. The CI token legitimately rolls out Deployments into the shop's namespace. If it leaks, the attacker rolls out a Pod running as root with the node disk, and RBAC won't stop that. The lesson shows how to turn on Pod Security Admission on a live namespace without taking the services down.
Threat model
The attacker has the ServiceAccount token that CI uses to roll out the application. It is allowed to create Deployments. Anything the attacker rolls out runs with whatever security fields they write into the Pod template.
Attack path
- A CI token with the create deployments permission.
- A Deployment with a privileged container running as root and a volume with the node's root filesystem.
- The Pod sends the administrator's kubeconfig to an external server.
Checklist
- Application namespaces have
enforce: restricted, or at leastbaseline, and the level version is pinned. warnandauditran beforeenforcewas turned on, and the violations were sorted out.- After turning it on,
rollout statusof every workload is checked, not just the exit code ofapply. - Pod templates are checked with a server-side dry-run, so running Pods don't hide violations.
- Only those who manage the cluster can change namespace labels.
Practice
One lab on the shared cluster of the track. The attack rolls out a privileged Deployment with the CI token. You turn on restricted for shop, move web, api and PostgreSQL to running without root, and check that the attack runs into Pod Security while the shop still takes orders.
Done reading?
Mark the lesson as read to move your track progress forward.
Lesson marked as done.
Practice
Fix a local lab. The agent checks your work and gives hints if you get stuck.
Full access to all labs
One payment, no auto-renewal · Terms
Progress saved in this browser
Clear your history or open this on your phone, and the marks will be gone. Leave your email and they'll move to your account. No password needed.
Done. moved to your account. You can see your progress on any device. My progress