A pentest finds 300 workloads running as root, many with `privileged: true`. How do you remediate without breaking production?
IntermediateScenarioSecurity incidents
Answer
Situation read → Turning on enforcement tomorrow would break deploys. Measure first, fix gradually, then enforce.
What I'd do →
- Label namespaces with Pod Security Admission in warn and audit mode at
restricted, so you see violations without blocking anything.
kubectl label ns shop pod-security.kubernetes.io/warn=restricted \
pod-security.kubernetes.io/audit=restricted
- Build a report of violations per team, and work out which privileged pods actually need it (CNI, CSI drivers, node agents). Those go in a dedicated system namespace with an exception.
- Fix images: add a non-root
USER, make writable paths explicit (emptyDir), drop all capabilities. - Give teams a secure default in the Helm chart or base Kustomize:
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities: { drop: ["ALL"] }
seccompProfile: { type: RuntimeDefault }
- Switch namespaces to
enforceone by one as they go clean, and block new violations in CI with Kyverno or Conftest.
Why → Warn → fix → enforce avoids breaking production and stops the problem from growing.
Interview tip → Mention that some system components really do need privileges; blanket enforcement breaks the cluster.
More on Security incidents
An AWS access key for a production IAM user was pushed to a public GitHub repo 20 minutes ago. What do you do in the first 30 minutes?AdvancedYou find pods in your cluster running a crypto miner. What do you do?AdvancedA critical CVE is announced in a library you use. You have 200 images across 40 repos. How do you find and patch everything fast?IntermediateGuardDuty reports an EC2 instance talking to a known command-and-control IP. What do you do?AdvancedYou discover an S3 bucket with customer data has been public for three months. What now?IntermediateAn engineer left the company three weeks ago and you find their access key was used yesterday. How do you respond and fix the process?Beginner