PodSecurityPolicy Migration Leftover Disables PodSecurity
Overview
A single stray plugin name in a kube-apiserver flag can strip PodSecurity enforcement from every namespace at once, including kube-system, letting container specs carrying privileged: true, hostPID or hostNetwork pass admission unchecked. RBAC and NetworkPolicy provide no backstop, since neither governs container capability grants on the control plane.
At a glance
- Symptom
- A pod spec anywhere in the cluster sets privileged: true, hostPID: true or hostNetwork: true and is admitted without any pod-security.kubernetes.io check.
- Likely cause
- kube-apiserver started with --disable-admission-plugins=PodSecurityPolicy,PodSecurity, removing the PodSecurity admission plugin from the enabled set.
- Impact
- Every namespace, including kube-system, accepts privileged containers with no admission-time enforcement or audit trail.
- Verification signal
- Re-run the detection test and a controlled negative-path test.
- Safe correction
- Audit static kube-apiserver manifests directly for stray PodSecurity entries in --disable-admission-plugins and confirm denial with a synthetic privileged pod test.
- Rollback or recovery
- Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
The Trap
A stray plugin name in kube-apiserver’s –disable-admission-plugins flag, carried over from a PodSecurityPolicy migration script, that removes the PodSecurity admission plugin from the enabled set cluster-wide.
The Default State
During the 1.21–1.25 PodSecurityPolicy deprecation window, migration runbooks instructed operators to strip PodSecurityPolicy from –enable-admission-plugins and add it to –disable-admission-plugins on every control-plane node. Engineers copy-pasted this instruction into the rollout that introduced the PodSecurity admission plugin and, assuming the two names referred to the same retiring feature, appended “PodSecurity” to the identical disable list.
The static pod manifest at /etc/kubernetes/manifests/kube-apiserver.yaml ends up with –disable-admission-plugins=PodSecurityPolicy,PodSecurity, and kube-apiserver restarts cleanly with no warning that a second, unrelated plugin has just been switched off.
The Blast Radius
With PodSecurity absent from the enabled plugin set, kube-apiserver stops evaluating pod-security.kubernetes.io/enforce labels on any namespace, including kube-system and default. Every PodSpec is admitted unchanged: privileged: true, hostPID: true, hostNetwork: true and arbitrary hostPath mounts all pass validation. There is no rejection, no webhook denial, no distinct audit entry, because the checks that would generate them never execute.
Existing NetworkPolicy and RBAC controls do not compensate, since they govern traffic and API access rather than container capability grants. Often nothing is noticed until a compromised workload escapes to its host node through a privileged pod or hostPath mount, by which point an attacker may already be moving laterally.
The Lead Mechanic Fix
Audit every control-plane node’s static manifest directly rather than trusting kubeadm’s stored config: grep /etc/kubernetes/manifests/kube-apiserver.yaml for –disable-admission-plugins and confirm PodSecurity is absent from the value, then check the live command line on each node (ps -ef | grep kube-apiserver), which can differ from the file.
Where kubeadm-managed, back up /etc/kubernetes, correct apiServer.extraArgs in the kubeadm-config ConfigMap, then regenerate the manifest one control-plane node at a time with kubeadm init phase control-plane apiserver –config <file>, so the stored config and the manifest agree and a later kubeadm upgrade does not reintroduce the flag.
Confirm restoration by submitting a synthetic pod spec with privileged: true against a namespace labelled pod-security.kubernetes.io/enforce=restricted using kubectl apply –dry-run=server; the request must be denied with a PodSecurity violation message before the fix is considered complete. To catch a recurrence, alert with absent() when the apiserver_admission_controller_admission_duration_seconds_count{name=”PodSecurity”} series disappears.
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Audit static kube-apiserver manifests directly for stray PodSecurity entries in --disable-admission-plugins and confirm denial with a synthetic privileged pod test.
Validate the vendor-specific syntax in official documentation before applying it.
Verify, roll back or escalate
Verify
Re-run the detection test and a controlled negative-path test. Confirm the unsafe behaviour is blocked while approved traffic still succeeds.
Rollback
Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Last updated
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Found this useful? Follow KBY for more like it.
