Description
Set allow_privilege_escalation = false in the Linux container’s security_context. It sets no_new_privs, restricting new privileges from setuid executables and file capabilities.
Potential impact
Processes retain permissions they already hold. Privileged containers and containers with the SYS_ADMIN capability allow privilege escalation.
Remediation
Remove privileged mode and unneeded capabilities, and run with a least-privileged user. Apply the setting to shared Pod templates and Helm charts, then test the executables your application needs.
Examples
Replace the example’s nginx:1.7.9 with a supported image for deployment.
Before
resource "kubernetes_pod" "app_pod" {
metadata {
name = "terraform-example"
}
spec {
container {
image = "nginx:1.7.9"
name = "app-container"
security_context {
allow_privilege_escalation = true
}
}
}
}
After
resource "kubernetes_pod" "app_pod" {
metadata {
name = "terraform-example"
}
spec {
container {
image = "nginx:1.7.9"
name = "app-container"
security_context {
allow_privilege_escalation = false
}
}
}
}
The second example restricts privilege gains through executable files in the same app-container.