Cloud Security

5 Steps to Audit Kubernetes NetworkPolicies in Production

November 7, 2026 · 5 min read · By CloudAI Security
5 Steps to Audit Kubernetes NetworkPolicies in Production

Kubernetes NetworkPolicy audit in five steps: inventory which namespaces carry any policy at all, probe isolation with throwaway test pods, confirm your CNI actually enforces the API, roll out default-deny namespace by namespace, then re-verify egress and DNS rules against real traffic. Most audits keep finding the same gaps for one structural reason: every pod accepts all inbound and outbound connections until a NetworkPolicy selects it. Any namespace without a policy is a flat network, and a single compromised pod there can reach every other workload in the cluster.

This review covers the network layer only. Run it alongside a pod security admission gap review, because tightening traffic between pods buys little if those pods still run privileged with broad service account tokens.

Start With a Coverage Inventory

List every policy in the cluster and match it against namespaces: kubectl get networkpolicies -A. Namespaces that return nothing are your flat networks, and they are where an attacker gains lateral movement for free. Record the owner of each namespace as you go, because remediation means someone has to write rules for workloads they understand.

Then inspect what each existing policy actually selects, because two traps hide inside YAML that looks complete. An empty podSelector selects all pods in the namespace, while a selector referencing labels no workload carries selects nothing and protects nothing. Similarly, when policyTypes is omitted, Kubernetes treats the policy as ingress-only unless egress rules are present, so half-written policies look enforced while leaving outbound traffic wide open.

The table below is the triage sheet I use on a first pass. It is a review method, not a measured result: each signal tells you what to fix next.

Audit signalWhat it revealsFix
Namespace with zero NetworkPoliciesFlat east-west network, unrestricted pod-to-pod reachApply a deny-all baseline, then allow selectively
Ingress-only policyTypesEgress unrestricted; data can leave the namespace freelyAdd Egress and enumerate real destinations
ipBlock with a node or VPC-wide CIDRThe rule effectively allows the whole networkNarrow to required CIDRs and ports
Selectors matching no live labelsPolicy selects nothing; protection is illusoryRe-map selectors to actual workload labels

Probe Isolation With Test Pods

Inventory shows what exists; probing shows what works. As a worked example, deploy a short-lived BusyBox pod in each namespace and attempt the connections that policy should block: the database port of another namespace, an external IP address, a service that only one caller may use. Log every attempt that should have failed but succeeded, because each success marks a missing or malformed rule. Delete the probe pods when the pass is done, and re-run the pass after every policy change, since policies drift as teams add rules under deadline pressure and nobody volunteers to delete permissions.

Check Your CNI Enforcement Mode

The most expensive false positive in this audit is a policy that is applied but never enforced. The upstream documentation is blunt: creating a NetworkPolicy without a supporting network plugin changes nothing, because a NetworkPolicy resource has no effect when no controller implements it, and EKS clusters keep the VPC CNI policy feature disabled until you set ENABLE_NETWORK_POLICY to true. Confirm enforcement first. On EKS, inspect the vpc-cni add-on configuration; on other distributions, verify that the CNI in use actually implements the NetworkPolicy API. Skip this check and every later step audits paper instead of traffic.

Default-Deny, Then Allow Selectively

The order of the rollout matters more than the individual rules. The Amazon EKS best practices guide tells teams to follow least privilege with network policies and start with a deny-all policy that restricts all inbound and outbound traffic inside a namespace, then layer narrow allow rules on top. A safe sequence looks like this:

  1. Apply the deny-all NetworkPolicy to one non-critical namespace first.
  2. Add an egress rule allowing DNS queries to kube-dns over UDP on port 53, or nothing resolves and every test is ambiguous.
  3. Add narrow per-workload ingress and egress rules, smallest surface first.
  4. Watch application logs for blocked traffic that should be allowed, fix the rule, and repeat with the next namespace.

Verify Egress and DNS Rules

Egress is where audits usually end, and egress rules rot faster than ingress rules: destinations change, services migrate, and a rule written for last year’s architecture quietly permits far more today. Walk each egress rule and ask whether the destination still exists, whether the port list matches what the workload opens now, and whether any rule grants more than it did when written. Make the walk periodic rather than a one-off, using the same monthly cadence that makes storage exposure drift signals worth reviewing.

Finally, scope expectations before the audit report promises too much. NetworkPolicies only filter traffic at OSI layers 3 and 4, and the API has no layer-7 or TLS inspection — no hostname-based egress filtering, no protocol awareness, and no native way to log blocked connections. If the review demands any of those, the answer is a service mesh or an egress gateway, not another NetworkPolicy.

Sources