Skip to main content

More Info:

Namespaces without NetworkPolicy objects allow unrestricted pod-to-pod traffic. Every namespace holding user workloads should have at least one NetworkPolicy defined.

Risk Level

High

Address

Security

Compliance Standards

  • CIS GKE

Triage and Remediation

Remediation

Manual Steps

  1. List namespaces missing NetworkPolicy objects
    Run on: any machine with kubectl access
    Save the output list of namespaces; you will create at least one NetworkPolicy in each.
  2. For a selected namespace, create a baseline “default deny ingress” NetworkPolicy
    Run on: any machine with kubectl access
    Replace TARGET_NAMESPACE with the namespace you are fixing (for each namespace, repeat with its name):
  3. (Optional but recommended) Add a default deny egress policy for the namespace
    Run on: any machine with kubectl access
    Replace TARGET_NAMESPACE with the namespace name:
  4. (Optional) Create explicit allow policies to restore required traffic
    Run on: any machine with kubectl access
    Example: allow all pods in the same namespace to talk to each other (adapt as needed per application):
  5. Repeat for all namespaces that were missing NetworkPolicies
    Run on: any machine with kubectl access
    For each namespace identified in step 1, create at least one NetworkPolicy (for example, the default deny policies plus any needed allow rules) by repeating steps 2–4 with the appropriate namespace name.
  6. Verify all namespaces now have at least one NetworkPolicy
    Run on: any machine with kubectl access
    The check is remediated when the command prints ALL_NAMESPACES_HAVE_NETWORK_POLICIES.
Create a baseline, deny-all-ingress / allow-all-egress NetworkPolicy for each workload namespace:
Apply the NetworkPolicies:
Verification (rerun the benchmark audit logic):