Skip to main content

Deny blast-radius preview (`internal/denysim` + `internal/counterfactual`)

Review-only answer to: if I added this emergency deny and flipped enforce, which observed traffic would it have matched?

This is not the multi-hop dependency walk in docs/blast-radius.md and not the CiliumNetworkPolicy review in insights.PolicyBlastRadius. There are two complementary paths:

PathEvidenceEndpoint / CLI
LiveLatest non-stale AgentReport aggregates (internal/denysim)POST /api/v1/ebpf/deny/preview
HistoryBounded flow deltas (internal/flowlog via internal/counterfactual)POST /api/v1/ebpf/deny/preview-history, or deny-preview … --since 1h

Console​

Diagnostics → Deny Preview posts to the same live and history endpoints, always shows the API caveat, and never applies a rule. Prefer live for DNS/SNI/process when historical name fields are empty.

Live preview​

netractl ebpf deny-preview cidr 203.0.113.0/24 egress
netractl ebpf deny-preview ip 1.1.1.1 both --protocol UDP --port 53
netractl ebpf deny-preview dns evil.example
netractl ebpf deny-preview sni cdn.example --namespace prod
netractl ebpf deny-preview process curl
netractl ebpf deny-preview port 445 --protocol TCP

POST /api/v1/ebpf/deny/preview

{
"kind": "cidr",
"value": "203.0.113.0/24",
"direction": "egress",
"protocol": "TCP",
"namespace": "prod",
"limit": 50
}

kind is one of ip, cidr, port, dns, sni, process. direction defaults to both. The handler writes nothing to the store, records no audit event, and does not change observe/enforce.

MCP tool: netra_ebpf_deny_preview (read-only; available even when NETRA_MCP_ALLOW_MUTATIONS is off).

Historical preview​

Uses the controller's flow history (default 7 days / 100000 records; see flow-log.md):

netractl ebpf deny-preview cidr 203.0.113.0/24 egress --since 1h
netractl ebpf deny-preview port 445 --protocol TCP --since 24h

POST /api/v1/ebpf/deny/preview-history — same body as live preview, plus optional since (duration up to 168h or RFC3339; default 1h). process is rejected (use live preview). DNS/SNI matches need those fields on retained rows; they are often empty today, so prefer live preview for name-based denies.

MCP tool: netra_ebpf_deny_preview_history (read-only).

Evidence boundaries​

  • Live hits are cumulative counters from the current agent snapshot.
  • History hits are retained flow deltas evaluated by internal/counterfactual (FlowLogStore). Not a column store; first sample after a restart is a baseline only.
  • A miss means Netra did not observe (or retain) matching traffic in the window. It does not mean the destination is unused, or that enforce would be a no-op.
  • process matching (live only) uses sampled FastPathEvent rows and comm only — not a cryptographic workload identity.
  • Stale agents are counted and skipped on the live path.
  • Live truncated: true means more groups existed than limit (default 50, max 200). Totals still include the truncated groups.
  • Every response carries a caveat string. Do not render hits as "would be blocked in production" without that sentence.

Validation​

internal/denysim/denysim_test.go covers live CIDR matching with stale-agent skip, exact IP + port filters, DNS/SNI name match (case-insensitive), sampled process events, and rejected unknown kinds.

internal/counterfactual covers FlowLogStore mapping, PolicyFromEmergencyDeny, and evaluate-over-history.

No kernel/BPF component — standard go test ./internal/denysim ./internal/counterfactual ./internal/api is sufficient.