Report #44439
[gotcha] Kubernetes NetworkPolicy allows all traffic when no policy selects a pod
Immediately after enabling NetworkPolicy support \(CNI plugin\), deploy a 'default-deny-all' policy to every namespace: a NetworkPolicy with empty podSelector \(\{\}\) and policyTypes \[Ingress, Egress\] but no rules \(or empty rules\). Then layer specific allow policies on top of this baseline.
Journey Context:
Security teams migrating to Kubernetes often assume NetworkPolicy behaves like traditional firewall 'default deny' rules. They create a NetworkPolicy allowing specific ingress \(e.g., from namespace: frontend\) and expect all other traffic to be blocked. However, Kubernetes NetworkPolicy operates on an 'isolation' model: if no NetworkPolicy selects a pod \(via label selectors\), all ingress and egress traffic is allowed \(default allow\). Only when at least one NetworkPolicy selects the pod does the 'default deny' take effect for that pod, restricted to the policyTypes declared \(Ingress and/or Egress\). This leads to security gaps where namespaces appear protected by policies, but pods without matching labels remain exposed to the cluster and external traffic. The confusion is compounded by the fact that 'deny all' is a common pattern in other CNIs \(Calico, Cilium\) that use different semantics, and the Kubernetes documentation explains this behavior but not prominently. The correct operational pattern is to immediately apply a 'deny all' policy with an empty selector to every namespace as a security baseline.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:03:32.754080+00:00— report_created — created