More Info:
Sharing the host network namespace exposes node network interfaces and bypasses network policies. Enforce policies that restrict admission of hostNetwork containers.Risk Level
HighAddress
SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify all pods using
hostNetworkacross the cluster- Run on: any machine with kubectl access
- Command:
- Review: Determine which are platform/infra components (e.g., CNI, DNS, ingress) vs. user workloads; list user workloads that use
hostNetwork.
-
Review existing admission controls / policies per namespace
- Run on: any machine with kubectl access
- Commands:
- Review: For each user-workload namespace, check if there is any admission controller (e.g., OPA Gatekeeper, Kyverno, custom webhooks) or policy that explicitly restricts
spec.hostNetwork: true. Note which namespaces lack such protection.
-
Determine business/operational need for each
hostNetworkpod- For each user-workload pod from step 1, review deployment manifests and owners:
- Decide with application owners whether
hostNetworkis truly necessary (e.g., low-latency network access, node-local ports). Document which workloads can drophostNetworkand which must retain it.
- For each user-workload pod from step 1, review deployment manifests and owners:
-
Plan and apply namespace-level admission policies to restrict
hostNetwork- Choose or confirm your admission mechanism (e.g., Kyverno, OPA Gatekeeper, custom webhook).
- For each user-workload namespace that should disallow
hostNetwork, create/update a policy that:- Denies new pods (and controllers: Deployments, DaemonSets, etc.) with
spec.hostNetwork: true, except for explicitly allowed labels/namespaces.
- Denies new pods (and controllers: Deployments, DaemonSets, etc.) with
- Apply policy manifests from any machine with kubectl access:
- Ensure policies are scoped per-namespace as required by your governance.
-
Refactor or reconfigure existing workloads to stop using
hostNetworkwhere possible- For each pod that does not strictly require
hostNetwork:- Update the workload manifest (Deployment/StatefulSet/DaemonSet/etc.) to remove or set
hostNetwork: false.
- Update the workload manifest (Deployment/StatefulSet/DaemonSet/etc.) to remove or set
- Apply the updated manifest from any machine with kubectl access:
- Coordinate with application teams and schedule changes to avoid disruption; be aware that networking behavior (ports, policies, source IPs) will change.
- For each pod that does not strictly require
-
Verify effectiveness of policies and remaining
hostNetworkusage- Confirm that new
hostNetworkpods are blocked in protected namespaces (expect admission denial): - Re-run the audit query to ensure only justified workloads use
hostNetwork: - Confirm that any remaining
hostNetworkpods are documented, approved exceptions and that corresponding namespaces still have admission policies in place.
- Confirm that new
Using kubectl
Using kubectl
Using kubectl
1. List pods that request hostNetwork
Run on: any machine with kubectl access.HOSTNETWORK = true) is using the host network and must be reviewed for necessity and risk.To see details for a specific pod:.spec.hostNetwork: true and the pod’s purpose.2. Discover whether pod security controls exist
a. Pod Security admission labels on namespaces (if using built-in PSA)pod-security.kubernetes.io/* labels, or are labeled with an overly-permissive level (e.g., privileged) likely do not restrict hostNetwork.Check a specific namespace:metadata.labels for pod-security.kubernetes.io/enforce (or audit/warn). Levels restricted/baseline are stricter; privileged means essentially unrestricted.b. PodSecurityPolicy (legacy clusters only)Check if PSP is enabled and list existing policies:
hostNetwork: true without clear justification or scoping. In a PSP YAML, look at:c. Admission webhooks / OPA / Gatekeeper / Kyverno (if used)List all Mutating/ValidatingWebhookConfigurations:
spec.hostNetwork, or policy engines (OPA Gatekeeper, Kyverno, etc.) installed without any constraints/policies targeting hostNetwork. You will need to review the webhook/policy definitions themselves (in the policy engine’s CRDs) to determine whether hostNetwork is restricted.3. Verify after policy decisions
After you adjust policies (outside the scope of kubectl alone), re-run:HOSTNETWORK=true pods remain, they should be explicitly approved exceptions; otherwise, they indicate a remaining policy gap.Automation
Automation

