Pod Security exemptions survive namespace labels, so audit them separately
Kubernetes Pod Security Admission applies the Pod Security Standards to pods based on namespace labels. A namespace with pod-security.kubernetes.io/enforce: restricted is supposed to reject workloads that violate the restricted profile. The Admission Controller also supports exemptions configured in its own API configuration. When a request matches an exemption, all enforcement, audit, and warning behavior is skipped.
That makes exemptions a cluster-level security control, not a namespace annotation. A team can believe a namespace is protected because the label says restricted, while a globally exempt username, runtime class, or namespace bypasses the profile. The Kubernetes documentation says exemption dimensions include usernames, runtime classes, and namespaces. The request matching an exemption is ignored by the Admission Controller.
Namespace labels are not the whole policy
Pod Security Admission configuration can set cluster-wide defaults and exemptions. The configuration object is separate from the labels on individual namespaces. Review it with the same care as the kube-apiserver admission configuration. Restrict write access to the configuration resource or the file that contains it. A change to an exempt username can affect every namespace in the cluster.
The audit annotation pod-security.kubernetes.io/exempt can identify whether a request was exempted by user, namespace, or runtime class. The metric pod_security_exemptions_total counts exempt requests and is useful for detecting unexpected use. Neither signal proves that an exemption is necessary. They show where to ask the ownership question.
Enforcement applies to pods, while audit and warning modes also apply to workload resources that create pod templates. A workload object can produce an audit finding before its controller creates a pod. Do not conclude that a Deployment is compliant because its template was accepted in a namespace that lacks enforcement. Check both the workload and the resulting pod.
Design exemptions as named exceptions
An exemption should have an owner, a reason, a scope, an expiration review, and a compensating control. A system namespace may need to run a privileged node agent. A build system may need a controlled runtime class. The exception should name the smallest user, namespace, or runtime class that covers the need.
Avoid exempting a broad shared service account. If several workloads use that account, the exemption grants them all the same bypass. Do not exempt an entire user group unless the group is tightly controlled and its membership is auditable. Review impersonation permissions because a user who can impersonate an exempt username may inherit the exemption path.
Compensating controls can include admission policy outside Pod Security Admission, namespace isolation, a dedicated node pool, image provenance checks, and mandatory audit review. The compensating control should be testable. A policy that says "the platform team reviews logs" without a named query, owner, and retention period is not a complete control.
Test the bypass and the removal
In a test cluster, create a pod that violates the restricted profile under a non-exempt identity. Confirm that it is rejected. Then use each exemption dimension and confirm that the same pod is accepted. Check the audit annotation and the exemption metric. Repeat after changing the namespace label to confirm that the exemption still controls the result.
Remove one exemption and observe which workloads fail. A sudden failure may expose a hidden dependency, but it also demonstrates that the exemption was carrying real authority. Plan the migration before removing the exception. Use a dedicated test namespace and avoid placing unsafe workloads into production to see what happens.
Keep the exemption configuration readable to the security team without exposing unrelated secrets. Log changes and review them after cluster upgrades because the admission configuration format and defaults can change. The safest exemption is one that is visible, narrow, and tested again after every change.
Top comments (0)