Description
In a legacy PSP, allowed_capabilities lists extra Linux capabilities that containers may request. Listing a capability does not grant it to every workload.
Potential impact
If unnecessary capabilities are granted, a compromised container can access more system functions.
Remediation
Check what the Pods request and keep only required entries. Drop unwanted default capabilities separately and limit exceptions to the workloads that need them. Kubernetes deprecated PSP in 1.21 and removed it in 1.25. Use Pod Security Admission or a policy engine on current clusters.
Examples
The first excerpt permits NET_BIND_SERVICE, which a service may need to bind to a low port. The second removes this allowance and disables privileged execution and privilege escalation. Verify that the service can still listen on its configured port.
Before
resource "kubernetes_pod_security_policy" "policy" {
metadata {
name = "terraform-example"
}
spec {
allowed_capabilities = ["NET_BIND_SERVICE"]
}
}
After
resource "kubernetes_pod_security_policy" "policy" {
metadata {
name = "terraform-example"
}
spec {
privileged = false
allow_privilege_escalation = false
}
}