Description
In a legacy PodSecurityPolicy, allowed_unsafe_sysctls lists the kernel settings Pods may request. The Pod supplies the value, and the kubelet must also allow it.
Potential impact
A pattern such as kernel.msg* can authorize more settings than the workload needs. Their values can affect node resources or isolation between Pods.
Remediation
Remove unnecessary patterns and choose safe sysctls for your Kubernetes and kernel versions. For an essential exception, test the value, limit the kubelet allow-list and restrict scheduling to dedicated nodes. Check workload operation and policy enforcement.
Examples
PSP was deprecated in Kubernetes 1.21 and removed in 1.25. These excerpts require the legacy API and provider. Use Pod Security Admission or a policy engine on current clusters.
Before
resource "kubernetes_pod_security_policy" "policy" {
metadata {
name = "terraform-example"
}
spec {
allowed_unsafe_sysctls = ["kernel.msg*"]
}
}
After
resource "kubernetes_pod_security_policy" "policy" {
metadata {
name = "terraform-example"
}
spec {
privileged = false
allow_privilege_escalation = false
}
}
The second policy drops the kernel.msg* allowance. privileged and allow_privilege_escalation control separate container permissions.