More Info:
Verifies allowPrivilegeEscalation is false on every container. It defaults to true, letting a process gain more privileges than its parent.Risk Level
HighAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify all noncompliant Pods
- Run on: any machine with kubectl access
-
For Pods with a controller owner (Deployment/DaemonSet/StatefulSet/Job/CronJob), edit the controller manifest
- Pick one line from step 1 with
owner=Deployment/<ns>/<name>/...(or other controller kind) and note its kind and name. - Run on: any machine with kubectl access
- In the editor, under each
containers:andinitContainers:entry, ensure asecurityContextwithallowPrivilegeEscalation: false, for example:
- Save and exit; Kubernetes will roll out updated Pods.
- Pick one line from step 1 with
-
For naked Pods without an owner, export and edit the Pod spec, then recreate it
- Pick a line from step 1 where
owner=is empty and note its namespace and name. - Run on: any machine with kubectl access
- Edit the file:
- Under
.spec.containers[]and.spec.initContainers[], add or update:
- Delete the existing Pod and recreate it from the edited manifest:
- Pick a line from step 1 where
-
Repeat edits for all remaining noncompliant controllers and Pods
- Use the output from step 1 as the source of truth.
- For each unique
owner=...entry, repeat step 2. - For each line with no
owner=, repeat step 3.
-
(Optional hardening) Add a default policy to prevent new Pods without this setting
- Run on: any machine with kubectl access
- Example: a
PodSecurityadmission label enforcingrestrictedin a namespace (if not already using Pod Security or Policy Controller):
-
Verify remediation
- Run on: any machine with kubectl access
- Confirm that the output is either
is_compliant=trueor contains no lines withis_compliant=false.
Using kubectl
Using kubectl
On any machine with kubectl access:
-
Identify non‑compliant Pods (from the audit output) and, for each Pod, determine its controller (Deployment, StatefulSet, DaemonSet, Job, CronJob, etc.) from the
owner=field in the audit output. You must patch the controller, not the live Pod. -
Example: patch a Deployment to set
allowPrivilegeEscalation: falsefor all containers (including initContainers) using a declarative manifest. a. Export the existing Deployment spec:b. Edit/tmp/deployment-<deployment-name>.yamland, under everycontainers[]andinitContainers[]entry in.spec.template.spec, ensure:IfsecurityContextalready exists, just add/updateallowPrivilegeEscalation: falseunder it. c. Apply the updated manifest:This will trigger a rolling update and recreate Pods from this Deployment with the new setting. -
Repeat the same export/edit/apply pattern for other controllers (DaemonSet, StatefulSet, Job, CronJob) that own non‑compliant Pods:
-
For standalone Pods without an owning controller (no
owner=in the audit output), recreate them from a manifest that explicitly setsallowPrivilegeEscalation: falseon every container and init container:Edit/tmp/pod-<pod-name>.yamlto add/update:Then delete and recreate: -
Verification (same machine with kubectl access):
Confirm all reported containers show
allowPrivilegeEscalation=falseandis_compliant=true(or onlyis_compliant=trueis printed).
Automation
Automation

