Skip to main content

More Info:

Containers sharing the host network namespace can access node network interfaces and bypass network segmentation. Their admission should be restricted via Pod Security Admission policies.

Risk Level

High

Address

Security

Compliance Standards

  • CIS AKS

Triage and Remediation

Remediation

Manual Steps

  1. Identify namespaces with user workloads
    • Run on: any machine with kubectl access
    Decide which namespaces contain user workloads (exclude core system namespaces such as kube-system, kube-node-lease, kube-public, gatekeeper-system, etc., unless you intentionally run user apps there).
  2. Review current Pod Security Admission labels on those namespaces
    • Run on: any machine with kubectl access
    Confirm whether pod-security.kubernetes.io/enforce is set to restricted (preferred) or a weaker level, and whether any warn labels are in use.
  3. Check for existing Pods using hostNetwork in each user-workload namespace
    • Run on: any machine with kubectl access
    For each listed Pod, determine if hostNetwork: true is strictly required for its function or is an unnecessary elevation.
  4. Decide the policy level per namespace based on business and technical need
    • For most user-workload namespaces, plan to enforce restricted, which disallows hostNetwork: true.
    • For namespaces that legitimately need hostNetwork (for example, certain node networking agents), consider:
      • Keeping them unlabelled or at baseline, and
      • Documenting the justification and who is allowed to deploy there.
  5. Apply or tighten Pod Security Admission labels on user-workload namespaces
    • Run on: any machine with kubectl access
    • To enforce restricted policy on a specific namespace (recommended default):
    • Optionally add a warning label at baseline cluster-wide to highlight less secure specs without blocking:
    Reassess any CI/CD manifests to ensure they no longer request hostNetwork: true in namespaces where restricted is enforced.
  6. Verify enforcement and resulting behavior
    • Confirm labels:
    • Attempt to create a test Pod with hostNetwork: true in a restricted namespace to confirm it is rejected (do not deploy in production namespace if you want to avoid noise; use a non-critical test namespace with the same labels):
    The admission request should be denied by Pod Security Admission in a restricted namespace, demonstrating that new hostNetwork pods are minimized.
What to look for (problem indicators)
  • Namespaces with user workloads that are missing pod-security.kubernetes.io/enforce or have it set to privileged or baseline.
  • Namespaces where you expect restrictions but see no pod-security.kubernetes.io/warn label either (no visibility into policy violations).

What to look for
  • ENFORCE is empty or privileged/baseline in namespaces that run user workloads.
  • WARN is empty where you want to be warned about non‑compliant Pods.

What to look for
  • Any line where hostNetwork is true in non‑system namespaces (i.e., not kube-system, gatekeeper-system, etc.).
  • These Pods are currently using the host network and may not be blocked by Pod Security Admission.

What to look for
  • Namespace prod has no pod-security.kubernetes.io/enforce=restricted label but contains Pods with hostNetwork=true.
  • This combination indicates a higher‑risk configuration needing human review.

What to look for
  • Events mentioning pod-security.kubernetes.io:
    • Messages like “violates PodSecurity ‘restricted’” for hostNetwork use (means enforcement is working).
    • Only warning annotations or no mention of PodSecurity (means hostNetwork might not be blocked).
What output indicates a problem:
  • Section 1:
    • User-workload namespaces with no pod-security.kubernetes.io/enforce label, or with a value weaker than your policy (e.g., unset where you expect restricted).
  • Section 2:
    • Any listed pod in a user-workload namespace using hostNetwork that is not explicitly justified by your security/design requirements.
  • Section 3:
    • Any namespace shown here is a higher-priority concern: it has hostNetwork pods but lacks enforce=restricted, so admission controls are not aligned with the benchmark guidance.