Skip to content

[Problem RFC] Pod Security Admission "restricted" label silently blocks pod recreation #887

Closed

Description

@TamimEhsan

Summary

A namespace gets the Pod Security Admission (PSA) enforce: restricted label as part of a security-hardening rollout. Nothing breaks immediately — PSA only gates admission, so already-running pods keep running. But the moment a pod is deleted (node drain, eviction, rollout, crash), the ReplicaSet's recreate attempt is rejected by the kube-apiserver itself with violates PodSecurity "restricted:latest", because the app's pods run as root / don't set a seccomp profile / don't drop capabilities. The deployment quietly goes under-replicated, and stays that way.

The trap: there is no webhook to find, no crash loop, no resource pressure, and no image problem. The Deployment spec, Service, and resources are all valid. The rejection happens at the namespace policy layer — a label on the Namespace object — which most diagnostic flows never inspect. The error only surfaces in ReplicaSet events, not in Deployment or Pod status.

Real-World Failure Story

Pod Security Admission replaced the deprecated PodSecurityPolicy and went GA in Kubernetes 1.25. The Pod Security Standards define three profiles (privileged, baseline, restricted); the restricted profile is the strictest and requires pods to explicitly set runAsNonRoot: true, drop all capabilities, and set a seccompProfile, among others.

The classic incident pattern is well documented as a failure class (rather than a single named company postmortem):

  • A platform team enables enforce: restricted on a namespace to satisfy a compliance requirement.
  • Existing workloads were built before these constraints — they run as root, omit a seccomp profile, or request added capabilities. They violate restricted but were never rejected, because PSA only checks pods at admission time, not pods already running.
  • The violation stays dormant until something forces a pod to be recreated — a node drain, an autoscaler scale-up, a rollout, or a crash. Then the new pod is denied and the service silently degrades.
  • A particularly subtle variant: an injected sidecar (service mesh, logging agent) adds a securityContext that violates the policy, so even a "compliant" app deployment fails admission once the sidecar is merged in.

This is documented across vendor and community guidance as a real operational footgun, with dedicated incident-response runbooks:

Honesty note for reviewers: unlike the webhook-timeout RFC (which maps to a specific filed incident, kubernetes/kubernetes#128162), this is grounded in a documented failure class with published runbooks rather than a single named company RCA. The mechanism, symptoms, and fix are all real and reproducible; the "famous postmortem" is what's missing.

Why this is a distinct failure class from the admission problems already in SREGym:

  • admission_webhook_outage, admission_webhook_tls_mismatch, mutating_webhook_resource_limits are all webhook problems — the agent's diagnostic path is "enumerate webhook configs, find the broken/Fail one."
  • PSA is built into the kube-apiserver — there is no ValidatingWebhookConfiguration or MutatingWebhookConfiguration to find. The policy lives as a label on the Namespace. Enumerating webhooks returns nothing; the agent has to look at namespace metadata, a genuinely different place. No existing problem touches PSA or the Pod Security Standards.

Proposed Simulation

Target application: Hotel Reservation (same single-namespace scoping as the existing admission problems; target a single-replica deployment such as recommendation).

Fault injection:

  1. Add the PSA enforce label to the app namespace:
    pod-security.kubernetes.io/enforce: restricted (optionally pin enforce-version).
  2. Confirm the target deployment's pods violate restricted (the demo images run as root / lack runAsNonRoot / lack a seccomp profile — true for the Hotel Reservation services).
  3. Delete one pod of the target deployment. The ReplicaSet's recreate attempt is rejected at admission; the deployment stays under-replicated.

(Existing running pods of other services are unaffected — PSA doesn't evict them — which reinforces the "everything looks fine except this one deployment" symptom.)

Expected symptoms:

  • The target deployment is under-replicated; the missing pod is never created.
  • ReplicaSet events show Error creating: pods "<name>" is forbidden: violates PodSecurity "restricted:latest": <specific violations> (e.g. allowPrivilegeEscalation != false, runAsNonRoot != true, seccompProfile).
  • No webhook configurations exist to explain it — enumerating Validating/MutatingWebhookConfiguration returns nothing relevant.
  • Deployment spec, image, Service, and resources are all valid.

Compatibility: Works on kind — PSA is a built-in admission plugin enabled by default since 1.25 (kind runs ≥1.25). Pure Kubernetes machinery, no host access, no control-plane saturation. Deterministic: the label either is or isn't present, and the violation is structural.

Expected Mitigation

Any of:

  1. Remove the pod-security.kubernetes.io/enforce: restricted label from the namespace (revert the hardening).
  2. Relax it to a profile the workload satisfies (e.g. baseline), or set enforce: privileged for that namespace.
  3. (Hardest / most production-correct) Make the workload compliant — add securityContext with runAsNonRoot, allowPrivilegeEscalation: false, dropped capabilities, and a seccompProfile — so it passes restricted.

Once admission stops rejecting the pod, the existing ReplicaSet recreates it with no further changes. The lesson: PSA enforcement is silent until a pod is recreated, and restricted rejects workloads that were never built for it.

Oracle Design

Diagnosis oracle: LLMAsAJudgeOracle — validates the agent identified the namespace PSA restricted enforcement (not a webhook, not the app) as the root cause.

Mitigation oracle: DeploymentReadinessOracle — passes only when the target deployment's ready_replicas == desired and all its pods are Running/Ready. This is the same oracle the existing webhook-outage problem uses: it reports failure while admission is blocked (the recreated pod is absent) and success once the workload can be admitted again. It accepts all three mitigation paths and resists reward-hacking (deleting the deployment / scaling to zero leaves it not-ready).

Implementation Notes

  • Follows the admission_webhook_outage.py lifecycle: in inject_fault() apply the namespace label and delete one target pod to surface the blocked recreate; in recover_fault() remove the label.
  • Apply the label via client.CoreV1Api().patch_namespace(...) (or kubectl label namespace ...), capturing any prior PSA labels so recovery restores the exact original state.
  • Reuse the existing DeploymentReadinessOracle and LLMAsAJudgeOracle — no new oracle needed.
  • Files: sregym/conductor/problems/psa_restricted_blocks_recreation.py (new), one import + one registry entry in sregym/conductor/problems/registry.py.
  • Verify on kind that the target Hotel Reservation deployment's pods actually violate restricted before wiring the oracle (they should, since the images run as root without a seccomp profile). If any chosen service happens to already be compliant, pick one that isn't.

References

Activity

  1. Saadmrp1038 commented on Jun 13, 2026

    @Saadmrp1038
    Collaborator

    @TamimEhsan Thanks for the RFC!
    Looks good to me. Although you might need to do some actual agent runs to see how the diagnosis and mitigation rates look for this. Ideally, the agent should not always manage to solve this. Otherwise, this might be too easy for the benchmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions