Pod Security Admission Not Enforced
No namespace enforces a Pod Security Standard, so anyone able to create pods can run privileged containers or mount the node's filesystem.
| Severity | High |
| CVSS 3.1 | 7.2 CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H Open in the calculator |
| CVSS 4.0 | 8.6 CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-1188: Initialization of a Resource with an Insecure Default |
| MITRE ATT&CK | T1610 Deploy Container, T1611 Escape to Host |
| Category | Security Misconfiguration |
Description
Pod Security Admission is the built-in Kubernetes admission controller that checks pods against the Pod Security Standards: Privileged, which is unrestricted; Baseline, which blocks known privilege escalations such as privileged containers, host namespaces, hostPath volumes and capabilities beyond a default set; and Restricted, which also requires non-root users, dropped capabilities, no privilege escalation and a seccomp profile. It replaced PodSecurityPolicy, which was removed in Kubernetes 1.25.
Each namespace selects a level through labels for three modes: enforce rejects violating pods, while audit and warn only record or display violations. A namespace without an enforce label falls back to the cluster default, which is Privileged unless the admission configuration sets another level. The weakness exists when no namespace, or only a few, enforce Baseline or Restricted, and no other policy engine, such as Kyverno, OPA Gatekeeper or ValidatingAdmissionPolicy rules, enforces equivalent controls.
Without enforcement, any user, pipeline or compromised workload that can create pods in a namespace can run a privileged pod, share the node's namespaces or mount its filesystem, and so gain root on a node, from where every pod scheduled there and the credentials they hold are exposed. Exploitation requires an identity that can create workloads, such as a developer or CI/CD credential or an over-privileged service account. Kubernetes' own guidance makes the same point, that users who can run privileged pods can use them to gain node access, and recommends enforcing Baseline or Restricted wherever pod creators are not fully trusted.
The weakness is identified by listing namespace labels with kubectl get namespaces --show-labels, reviewing the API server's admission configuration, and attempting to create a test pod that violates Baseline in an application namespace.
Remediation
- Label every application namespace to enforce at least Baseline, and Restricted wherever the workloads allow it; pin the policy version with the
-versionlabels if upgrades must not change behaviour. - Before enforcing, apply the level in
warnandauditmode, or run a server-side dry run, to find existing pods that would be rejected, and fix or document them. - Keep Privileged only for system namespaces whose components need it, and restrict who can create pods there.
- Set a cluster-wide default of Baseline in the PodSecurity admission configuration, so that new namespaces are protected without labels.
- Restrict who can change namespace labels, since the labels are the control.
Confirm the fix by attempting to create a privileged test pod in each application namespace and checking that it is rejected.
References
- kubernetes.io/docs/concepts/security/pod-security-admission
- kubernetes.io/docs/concepts/security/pod-security-standards
- kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-namespace-labels
- kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-admission-controller
- kubernetes.io/docs/concepts/security/rbac-good-practices
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.