Description
SYS_ADMIN allows many Linux administrative operations, including mounts. Use a narrower capability for an application that needs only a specific operation.
Potential impact
A compromised container may affect the node depending on its user namespace and other host access.
Remediation
Remove SYS_ADMIN from security_context.capabilities.add. Where possible, drop ALL and restore only what the workload needs. Restrict privileged mode, hostPath and host namespace sharing too. A container with SYS_ADMIN cannot rely on allow_privilege_escalation = false to prevent escalation.
Examples
The second excerpt removes the SYS_ADMIN addition. Runtime defaults may still apply. Verify the application’s required operations with a maintained image.
Before
resource "kubernetes_pod" "app_pod" {
metadata {
name = "terraform-example"
}
spec {
container {
image = "nginx:1.7.9"
name = "app-container"
security_context {
capabilities {
add = ["SYS_ADMIN"]
}
}
}
}
}
After
resource "kubernetes_pod" "app_pod" {
metadata {
name = "terraform-example"
}
spec {
container {
image = "nginx:1.7.9"
name = "app-container"
}
}
}