Description
In a legacy PSP, allow_privilege_escalation controls whether a Linux container may gain privileges when a program starts.
Potential impact
If escalation is allowed, a process can gain the permissions attached to a setuid executable or a file capability.
Remediation
Set allow_privilege_escalation = false in the spec of the legacy kubernetes_pod_security_policy. Remove privileged mode and SYS_ADMIN from the containers, review permissions they already hold, and check for other policies the workload can use.
Examples
The excerpts compare only this field. Kubernetes deprecated PSP in 1.21 and removed it in 1.25. On current clusters set allowPrivilegeEscalation: false in workloads, then verify that Restricted or an equivalent admission policy rejects a noncompliant Pod.
Before
resource "kubernetes_pod_security_policy" "policy" {
metadata {
name = "terraform-example"
}
spec {
allow_privilege_escalation = true
}
}
After
resource "kubernetes_pod_security_policy" "policy" {
metadata {
name = "terraform-example"
}
spec {
allow_privilege_escalation = false
}
}