More Info:
Verifies runAsNonRoot is set at pod or container level. Running as root inside a container widens the impact of a container escape.Risk Level
HighAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify non-compliant pods (run on any machine with kubectl access):
-
For standalone Pods (not controlled by a higher-level object), export, edit, and re-apply the manifest (run on any machine with kubectl access). Example for one pod:
Edit
/tmp/pod-POD_NAME.yamland add or adjust at the pod spec level:or, if you cannot set it at pod level, add it to every container and initContainer:Then re-create the pod (Pods are immutable): -
For pods owned by a controller (Deployment/ReplicaSet/StatefulSet/DaemonSet/Job/CronJob), edit the controller so all future pods are compliant (run on any machine with kubectl access). Example for a Deployment:
In the editor, under
spec.template.spec, set:If needed, also set on each container:Save and exit; Kubernetes will roll out updated pods. -
Repeat step 3 for other controllers (StatefulSet, DaemonSet, Job, CronJob) that own non-compliant pods, using
kubectl editon the appropriate resource type and settingspec.template.spec.securityContext.runAsNonRoot: trueor per-containersecurityContext.runAsNonRoot: true. -
If any image fails to start with
runAsNonRoot: true, review that image on your image build system: ensure the container’s default user is non-root (e.g., via aUSERdirective in the Dockerfile) or explicitly set a non-rootrunAsUsertogether withrunAsNonRoot: truein the pod spec, then redeploy. -
Verify compliance (run on any machine with kubectl access):
Using kubectl
Using kubectl
On any machine with kubectl access:Under If you cannot set it at pod level (e.g., mixed containers), set it on each container instead:Apply the same pattern to other controllers (StatefulSet, DaemonSet, Job, CronJob) using:For standalone Pods managed directly (not recommended in GKE production), edit and re-apply:Edit Then delete and recreate:
- Identify non-compliant Pods
- Edit each affected workload manifest and set pod-level
runAsNonRoot: true(preferred). For example, for a Deployment owning the Pod:
spec.template.spec, ensure:/tmp/pod.yaml to include:- Verification
Automation
Automation

