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 a standalone Pod (no owner/controller), edit the Pod manifest to set
runAsNonRoot: trueat pod level (preferred) or per container (run on any machine with kubectl access):Edit/tmp/pod-fixed.yaml:- Under
spec:, add or update: - Remove
metadata.resourceVersion,metadata.uid,metadata.creationTimestamp, andstatus:block. Apply the fixed manifest:
- Under
-
For pods managed by a controller (Deployment/StatefulSet/DaemonSet/Job/CronJob), patch the controller spec so all current and future pods inherit
runAsNonRoot: true(run on any machine with kubectl access). Example for a Deployment:If you must set it per container (e.g., pod-level context not desired), patch each container by name: -
If initContainers are present and not covered by pod-level
securityContext, ensure they also haverunAsNonRoot: true(run on any machine with kubectl access). Example for the first initContainer: -
For GitOps or manifest-driven environments, update the source manifests instead of live objects (run on any machine with repo access): in each PodTemplate (Deployment/StatefulSet/DaemonSet/Job/CronJob), set:
Commit and apply via your normal pipeline so changes persist.
-
Verification (run on any machine with kubectl access): re-run the audit and confirm only
is_compliant=trueremains, or nois_compliant=falselines:
Using kubectl
Using kubectl
On any machine with kubectl access:Edit Apply the updated manifest:For a naked Pod (no controller), edit and apply similarly:Note: Updating the pod template for controllers will recreate pods; direct Pod changes require deletion and re-creation.Verification (same machine with kubectl):
- Edit the affected Pod’s owning workload (Deployment, StatefulSet, etc.) manifest and set
runAsNonRoot: trueat pod level.
/tmp/deploy-run-as-non-root.yaml and ensure the pod template has:Automation
Automation

