Privilege Escalation Control
What you'll learn: How to prevent containers from gaining elevated privileges beyond what they were initially granted.
What Is Privilege Escalation?
By default, processes can sometimes request more privileges than they started with—similar to how a temporary worker might exploit loose security to gain manager-level access. In Kubernetes, the allowPrivilegeEscalation setting controls whether a process can gain more privileges than its parent process.
When set to false, you're saying: "This container must stay in its lane—no sneaky privilege upgrades allowed."
Why This Matters
Even if you run a container as non-root (like you learned in earlier lessons), certain system calls or file permissions could still let processes escalate privileges. For example, setuid binaries—programs that run with elevated permissions—could be exploited. Disabling privilege escalation blocks this attack vector.
Think of it like a security bracelet at a concert: your ticket gets you into the general area, but that bracelet can't magically upgrade you to backstage access.
Applying the Control
In your container security context, add:
securityContext:
allowPrivilegeEscalation: false
This directive ensures that even if malicious code or a compromised binary tries to escalate, the kernel will deny it.
Combining With Other Hardening
This control works best alongside runAsNonRoot: true and readOnlyRootFilesystem: true. Together, they create a defense-in-depth strategy: run unprivileged, prevent modifications, and block escalation attempts.
Key Takeaway:
Setting allowPrivilegeEscalation: false prevents containers from gaining more privileges than their parent process, blocking a common attack path even when running as non-root.