More Info:
Windows HostProcess containers run with host-level privileges on the node. Restrict their admission in workload namespaces.Risk Level
HighAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify Windows HostProcess workloads in user namespaces
- Run on: any machine with kubectl access
- Command (lists pods that explicitly request HostProcess):
- Repeat, but exclude known infrastructure namespaces (adjust as appropriate for your cluster):
-
Decide where HostProcess containers are allowed (policy design)
- For each user namespace, decide one of:
- No HostProcess allowed (typical for most workloads).
- HostProcess allowed only for specific, justified workloads (e.g., node maintenance agents).
- Document for each namespace whether HostProcess is: forbidden, tightly controlled, or not yet decided.
- For each user namespace, decide one of:
-
Review and, if needed, create/adjust admission controls (Pod Security or other)
- If using built-in Pod Security Admission labels, for each user namespace that should forbid HostProcess, label it with at least
baselineorrestricted(both disallow HostProcess): - If you use another admission controller (e.g., Gatekeeper, Kyverno), review existing policies to ensure they deny pods with
.securityContext.windowsOptions.hostProcess: truein any namespace that should not allow them. Use: - Where HostProcess must be allowed, design exception rules (e.g., labels/annotations on specific namespaces or service accounts) and ensure policies only allow HostProcess under those constrained conditions.
- If using built-in Pod Security Admission labels, for each user namespace that should forbid HostProcess, label it with at least
-
Implement or tighten deny policies for HostProcess in user namespaces
- Example Kyverno ClusterPolicy to deny all HostProcess containers except in explicitly allowed namespaces (
windows-hostprocess-allowed=true): - Apply (adjust as needed for your own policy engine):
- Example Kyverno ClusterPolicy to deny all HostProcess containers except in explicitly allowed namespaces (
-
Handle existing HostProcess pods in disallowed namespaces
- For each pod from step 1 that is in a namespace now marked to forbid HostProcess:
- Confirm with the owner whether the HostProcess capability is truly required.
- If not required: update the pod spec / owning controller (Deployment, DaemonSet, Job, etc.) to remove
.securityContext.windowsOptions.hostProcess: true, then redeploy. - If required: either
- move the workload to a dedicated namespace explicitly marked to allow HostProcess (e.g., label
windows-hostprocess-allowed=true), and keep strict controls there, or - adjust your policy design to formally permit it with documented justification.
- move the workload to a dedicated namespace explicitly marked to allow HostProcess (e.g., label
- For each pod from step 1 that is in a namespace now marked to forbid HostProcess:
-
Verify that HostProcess admission is now minimized
- Re-run the detection command to confirm there are no HostProcess pods in namespaces where they should be forbidden:
- Independently test admission by attempting to create a sample HostProcess pod in a user namespace that should reject it and confirm it fails with a policy error:
Confirm the admission controller rejects this pod creation.
- Re-run the detection command to confirm there are no HostProcess pods in namespaces where they should be forbidden:
Using kubectl
Using kubectl
-
Step 3 / 4 / 5 outputs:
- Any line where the last column is
truemeans there is at least one Windows HostProcess container currently running in that namespace. That is not automatically wrong, but such pods should be reviewed and justified; user-workload namespaces should generally not contain HostProcess containers unless there is a documented, approved need.
- Any line where the last column is
-
Step 2 / 6 / 7 outputs:
- If there are no Validating/Mutating webhooks or ValidatingAdmissionPolicies that reference
windowsOptionsorhostProcess, then there is likely no explicit admission control restricting Windows HostProcess containers. - In user-workload namespaces, “no hostProcess-related policies found” combined with evidence of HostProcess-true pods from steps 3–5 suggests a policy gap that needs human review and a possible policy design.
- If there are no Validating/Mutating webhooks or ValidatingAdmissionPolicies that reference
Automation
Automation

