Description
With hostPID: true, a legacy PSP allows a Pod to request the node’s process namespace.
Potential impact
Host process information may become visible to that container. What it can do to another process depends on its permissions.
Remediation
Set hostPID: false for ordinary workloads and reserve exceptions for system tools that need host PID access. Review hostIPC and hostNetwork too. Kubernetes deprecated PSP in 1.21 and removed it in 1.25. Enforce the same restriction with Pod Security Admission, Gatekeeper or Kyverno on current clusters.
Examples
Only hostPID changes. The seLinux.rule stays RunAsAny. Other required fields and use permissions are omitted. Verify that a test Pod requesting host PID access is rejected.
Before
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: example
spec:
hostPID: true
seLinux:
rule: RunAsAny
After
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: example
spec:
hostPID: false
seLinux:
rule: RunAsAny