Skip to main content

More Info:

Verifies allowPrivilegeEscalation is false on every container. It defaults to true, letting a process gain more privileges than its parent.

Risk Level

High

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. Identify all noncompliant Pods
    • Run on: any machine with kubectl access
  2. 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: and initContainers: entry, ensure a securityContext with allowPrivilegeEscalation: false, for example:
    • Save and exit; Kubernetes will roll out updated Pods.
  3. 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:
  4. 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.
  5. (Optional hardening) Add a default policy to prevent new Pods without this setting
    • Run on: any machine with kubectl access
    • Example: a PodSecurity admission label enforcing restricted in a namespace (if not already using Pod Security or Policy Controller):
  6. Verify remediation
    • Run on: any machine with kubectl access
    • Confirm that the output is either is_compliant=true or contains no lines with is_compliant=false.
On any machine with kubectl access:
  1. 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.
  2. Example: patch a Deployment to set allowPrivilegeEscalation: false for all containers (including initContainers) using a declarative manifest. a. Export the existing Deployment spec:
    b. Edit /tmp/deployment-<deployment-name>.yaml and, under every containers[] and initContainers[] entry in .spec.template.spec, ensure:
    If securityContext already exists, just add/update allowPrivilegeEscalation: false under it. c. Apply the updated manifest:
    This will trigger a rolling update and recreate Pods from this Deployment with the new setting.
  3. Repeat the same export/edit/apply pattern for other controllers (DaemonSet, StatefulSet, Job, CronJob) that own non‑compliant Pods:
  4. For standalone Pods without an owning controller (no owner= in the audit output), recreate them from a manifest that explicitly sets allowPrivilegeEscalation: false on every container and init container:
    Edit /tmp/pod-<pod-name>.yaml to add/update:
    Then delete and recreate:
  5. Verification (same machine with kubectl access):
    Confirm all reported containers show allowPrivilegeEscalation=false and is_compliant=true (or only is_compliant=true is printed).