Skip to main content

More Info:

Namespaces without NetworkPolicies allow unrestricted pod-to-pod traffic. Define policies to segment and restrict network flows.

Risk Level

High

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. List all namespaces and identify those without any NetworkPolicies
    • Run on: any machine with kubectl access
    • Compare the two lists and note any namespaces that do not appear in the NetworkPolicy list.
  2. Confirm traffic requirements for each uncovered namespace
    • For each namespace without a NetworkPolicy, gather workload and usage info:
    • With application owners, determine:
      • Which pods/services must be reachable from outside the namespace (and from where).
      • Which pods can talk to which other pods within the namespace.
      • Any external (egress) destinations that are required.
  3. Decide enforcement strategy per namespace
    • For each namespace, choose an approach:
      • Strict isolation: deny all ingress/egress by default and explicitly allow required flows.
      • Ingress-only control: restrict which sources can reach pods, leave egress open.
      • Baseline: start with a “deny-all” + explicit allow for known critical paths, plan to refine later.
    • Confirm with stakeholders that introducing NetworkPolicies will not unexpectedly break known traffic paths.
  4. Draft and apply appropriate NetworkPolicy manifests
    • Create one or more YAML files per namespace (examples to adapt, do not apply blindly):
    • Baseline deny-all ingress/egress for the namespace:
    • Example: allow ingress only from same namespace:
    • Apply after review:
  5. Validate connectivity and adjust policies
    • After applying policies, verify application behavior (health checks, functional tests).
    • If needed, iteratively relax or tighten rules (edit YAML, then re-apply):
  6. Re-run evidence collection to confirm coverage
    • Verify that all namespaces now have at least one NetworkPolicy and that policies match your intent:
    • Document which namespaces intentionally have specific NetworkPolicies and any namespaces (if any) that are intentionally left without them, including the risk rationale.
Review the list to understand the full scope of namespaces you must consider (including system namespaces like kube-system, kube-public, and any application namespaces).
Output interpretation:
  • Namespaces that show 0 in the count column have no NetworkPolicy objects defined.
  • Lack of any NetworkPolicy usually indicates unrestricted pod-to-pod traffic within that namespace (and from other namespaces, depending on the CNI behavior), which is what this control wants you to review and likely tighten.
Output interpretation:
  • Even if a namespace has one or more NetworkPolicies, they may not actually restrict traffic (for example, a policy that selects no pods, or allows all ingress/egress).
  • Use describe/-o yaml to review:
    • podSelector: which pods are affected.
    • policyTypes: Ingress, Egress, or both.
    • ingress / egress rules: whether they meaningfully restrict traffic or effectively allow everything.
Output interpretation:
  • Namespaces that have running pods but zero NetworkPolicies are typically the highest priority for review, since they are actively used and currently not segmented by policy.
These commands only surface the current state. A human must decide:
  • Which namespaces require isolation.
  • How strict ingress/egress should be for each namespace.
  • Whether some namespaces (e.g., certain system namespaces) should intentionally remain more permissive.
How to interpret the output
  • Lines starting with [WARN] in the summary and the list under Namespaces with NO NetworkPolicies indicate a problem: those namespaces currently have zero NetworkPolicy objects and therefore allow unrestricted pod-to-pod traffic by default.
  • These namespaces require manual review and design of appropriate NetworkPolicy objects based on application communication requirements. The script does not and cannot create policies automatically.