Skip to main content

More Info:

Containers with allowPrivilegeEscalation set to true can gain more privileges than their parent process. Enforce policies that restrict admission of such containers.

Risk Level

High

Address

Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Manual Steps

  1. Identify current use of allowPrivilegeEscalation across workloads
    • Run on: any machine with kubectl access
    • Command:
    • Save the output and review which namespaces/pods/containers currently rely on allowPrivilegeEscalation=true.
  2. Assess necessity and impact per workload
    • For each listed container:
      • Check its manifest:
      • Review with the workload owner whether privilege escalation is truly required (e.g., needs to setuid, load kernel modules, manipulate other users’ processes).
      • Classify each as: “must have”, “can be removed now”, or “needs migration work”.
  3. Design namespace-level policy using Pod Security Admission or a policy engine
    • If using Pod Security Admission (recommended for OKE where available):
      • Decide which namespaces need to run privileged or legacy workloads and which should be restricted.
      • Example: mark “restricted” namespaces to block privilege escalation:
    • If using a policy engine (e.g., Gatekeeper/Kyverno), plan a policy that denies pods where any container has securityContext.allowPrivilegeEscalation=true, with explicit exceptions for approved namespaces or workloads.
  4. Implement or tighten the policy and test against current workloads
    • Apply or update the chosen policy configuration (namespace labels or policy CRDs) according to your platform’s standard process.
    • Before enforcing, use “audit” or “dry-run” modes where supported to detect which existing pods/Deployments would be blocked:
      • For Pod Security Admission, inspect namespace warnings when applying manifests.
      • For Gatekeeper/Kyverno, check policy “audit” reports or kubectl describe on the policy object to see violations.
  5. Remediate or exempt necessary workloads
    • For each container classified as “can be removed now”:
      • Update its Deployment/StatefulSet/Pod manifest to explicitly set:
      • Apply the change:
    • For each “must have” or “needs migration work” workload:
      • Either place it in a dedicated namespace with a less-restrictive policy and clear justification, or define a narrowly scoped exception in your policy engine.
      • Document the justification and planned timeline for reduction where possible.
  6. Verify policy effectiveness and ongoing compliance
    • Re-run the evidence command:
    • Confirm that:
      • “Restricted” namespaces no longer admit new pods with allowPrivilegeEscalation=true.
      • Any remaining instances are explicitly approved exceptions with documented risk and controls.
Review which namespaces contain user workloads (exclude system namespaces such as kube-system, kube-public, kube-node-lease, and provider-specific system namespaces). For each user namespace, inspect current pods:
Output is a YAML stream; lines like:
or container-level:
indicate containers that currently allow privilege escalation and therefore should be reviewed.To see the full definition for a specific pod with a suspect setting:
Look for securityContext at both pod and container level; any explicit allowPrivilegeEscalation: true is a potential problem.Next, inspect whether the namespace has any admission policies (Pod Security Standards, PodSecurityPolicy if legacy, or custom policies) that would restrict such pods:
If there are no pod-security.kubernetes.io/* labels, or they are set to a privileged mode (e.g. privileged or a custom relaxed configuration elsewhere), the namespace likely does not restrict allowPrivilegeEscalation: true.If you are using admission webhooks (e.g., Gatekeeper, Kyverno), list related resources for review:
Absence of any constraints or webhook configurations that mention allowPrivilegeEscalation or container privilege in their names/annotations suggests the cluster may not be enforcing restrictions.Verification after any policy changes (manual, outside the scope of these commands):
Any remaining allowPrivilegeEscalation: true entries highlight pods that are either exempted by policy or running in namespaces without restrictive policies and need human review against your risk tolerance.