Skip to main content

More Info:

The NET_RAW capability allows crafting raw packets for spoofing and network attacks. Restrict its admission in workload namespaces.

Risk Level

High

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. Identify workload namespaces and existing policies
    • On any machine with kubectl access:
    • Decide which namespaces contain user workloads (exclude kube-system, monitoring, logging, etc. unless users run apps there).
  2. Review current use of NET_RAW in running workloads
    • On any machine with kubectl access, for each workload namespace (substitute the namespace name):
    • Record which applications currently rely on NET_RAW and confirm with the application owners whether it is truly required.
  3. Review admission controls that could restrict NET_RAW
    • On any machine with kubectl access:
    • For each mechanism you find, inspect whether it already forbids adding NET_RAW in workload namespaces (e.g., by disallowing capabilities.add or explicitly listing forbidden capabilities).
  4. Decide namespace-by-namespace policy for NET_RAW
    • For each workload namespace, make an explicit decision:
      • Forbidden: no containers should ever use NET_RAW.
      • Exception-only: NET_RAW allowed only for tightly controlled workloads.
    • Document the decision with justification (e.g., “prod namespace: NET_RAW forbidden; only network diagnostics namespace allows it”).
  5. Implement or tighten policies to enforce the decision
    • This is done by editing/adding Kubernetes policy objects (Pod Security Admission labels, Gatekeeper/Kyverno policies, or PodSecurityPolicy if present). There is no single command that applies to every cluster.
    • For the chosen mechanism, ensure policies for each workload namespace:
      • Reject pods that add NET_RAW unless they match an explicitly defined exception (e.g., label-based allowlist).
      • Apply policies to all relevant namespaces (via namespace labels, selectors, or target lists).
    • Use kubectl apply -f <policy-file>.yaml from any machine with kubectl access to create/update these policy objects.
  6. Verify that NET_RAW is effectively restricted
    • On any machine with kubectl access, in a workload namespace that should disallow NET_RAW, try to create a test pod:
    • Confirm that creation is rejected by the admission controls.
    • Re-run the inspection to ensure no admitted pods use NET_RAW unexpectedly:

Using kubectl

1. List all namespaces that may host user workloads

Run on: any machine with kubectl access.
What to look for:
The resulting list are candidate “user” namespaces where you should expect admission controls (Pod Security Admission, OPA/Gatekeeper, Kyverno, PSP if still used, etc.) to prevent NET_RAW.

2. Check for existing Pod-level security controls per namespace

2.1. Check Pod Security Admission labels (if PSA is in use)
Problem indication:
Namespaces used for user workloads that:
  • Have no pod-security.kubernetes.io/enforce label, or
  • Are labeled privileged or an overly permissive level,
    may allow pods with the NET_RAW capability unless another policy mechanism blocks it.

2.2. List any PodSecurityPolicies (legacy PSP clusters only)
Then, for each PSP:
Problem indication:
PSPs that:
  • Do not restrict allowedCapabilities, and
  • Do not list NET_RAW under forbiddenSysctls/capabilities-like controls (or otherwise constrain capabilities),
    are likely to permit NET_RAW. Also check RBAC bindings to see which namespaces/pods can use such PSPs.

2.3. Check common policy engines (if deployed)
Gatekeeper (OPA) constraints:
Then inspect:
Problem indication:
  • No constraints limiting container capabilities, or
  • Constraints that do not mention NET_RAW in disallowed capabilities, or
  • Constraints not selecting the user namespaces.
Kyverno ClusterPolicies/Policies:
Problem indication:
Policies do not contain rules that deny or mutate away NET_RAW, or are not applied (via match / exclude) to user namespaces.

3. Identify pods/containers that currently request or add NET_RAW

This is evidence gathering; existing pods may be noncompliant with your intended policy.
If jq is not available:
Problem indication:
Any line(s)/entries showing containers with:
either at the container level or via pod.spec.securityContext.capabilities.add. Those pods are using NET_RAW and should be reviewed to determine if the capability is truly required.

4. Check for Pod Security Standards violations (if PSA is enabled)

This does not directly “know” about NET_RAW but helps identify overly privileged pods.
If your cluster exposes PSA events via audit annotations, you can inspect a sample pod:
Problem indication:
  • Namespaces or pods not being evaluated by PSA, or
  • Pods running effectively at privileged level without other compensating policies, which makes it more likely they can use NET_RAW.

5. Optional: Dry-run admission test (non-production namespace)

Create a temporary test namespace:
Apply a pod that explicitly adds NET_RAW:
Problem indication:
  • If the dry-run succeeds (“pod/net-raw-test-pod created (server dry run)”), there is currently no admission control in that namespace preventing NET_RAW.
  • If the dry-run fails with a validation/admission error referring to capabilities or policies, then some control is in place; review the error text to confirm it is specifically blocking NET_RAW.
Clean up:
How to interpret the output
  • Any line under “Pods that explicitly ADD NET_RAW capability” indicates a problem for this control: those pods are being admitted with NET_RAW and should be reviewed; if not strictly required, they should be reconfigured to drop it and/or blocked by admission policy.
  • Lines under “Pods with privileged=true or ALL capabilities” are high‑risk candidates: they may effectively allow raw network operations even if NET_RAW is not explicitly listed. These require manual review to decide whether NET_RAW (or equivalent capability) is actually needed and whether to tighten security.
  • Namespaces listed under “Namespaces where any pod adds NET_RAW” are priority targets for creating or tightening admission policies (e.g., PodSecurity, PodSecurityPolicies where still in use, or external admission controllers) to restrict NET_RAW for user workloads.