Configure Blocking & Policies
Complete configuration guide with JSON examples for shirudo.firewall, shirudo.sandbox, shirudo.shield, and shirudo.watch, plus how nftables rule ordering and multi-namespace SOCK_DESTROY disrupt active tunnels.
Helix Cyber Defence policies are declarative JSON documents compiled into signed .hxsb bundles and enforced locally by cyberd. Every policy supports observe mode (dry-run telemetry without dropping packets) and enforce mode (active kernel drops and TCP socket teardown).
For an overview of the architecture and coverage boundaries, see Ingress & Egress Blocking.
How blocking and connection disruption work
When an enforced policy arrives on a node, cyberd executes two layers so that both new handshakes and already-established attacker tunnels are stopped immediately:
- New connection blocking (eBPF + atomic
nftables)cgroup/connect4andcgroup/connect6(including IPv4-mapped::ffff:x.x.x.xsockets) returnEPERMbefore a TCP SYN or connected UDP datagram leaves the kernel.cgroup_skb/ingressandtc_ingressdrop disallowed HTTP exploit paths and denied inbound L3/L4 traffic.- Atomic
table inet helix_cyberdcommitsff_input,ff_output, andff_forwardwithout touching Docker, kube-proxy, or CNI tables.
- Existing tunnel disruption (pre-established
nftables+ multi-netnsSOCK_DESTROY)- In
ff_output, enforcedoutbound.denyandoutbound.deny_torules are placed beforect state established,related accept. Underoutbound.default: "drop", the established-state rule is restricted toct direction replyso locally initiated outbound tunnels cannot bypass the default drop. - In
ff_input,ct direction replypackets returning from denied outbound destinations are dropped first, return packets of allowed outbound connections (ct state established,related ct direction reply accept) are preserved, and theninbound.deny_from,inbound.allow, andinbound.denyevaluate before any blanket established-state accept (which is omitted entirely underinbound.default: "drop"). Both unauthorized SSH and any other unallowed inbound sessions stop immediately. - In
ff_forward, enforced denies match both forward and reply directions ahead of established acceptance for routed Docker containers and Kubernetes pods. - Immediately after committing the ruleset,
cyberdrunsNETLINK_SOCK_DIAGSOCK_DESTROYon the host network namespace and across every unique container/pod network namespace found under/host/proc/<pid>/ns/net(using 4 parallel workers), immediately terminating live TCP tunnels withECONNABORTED/ TCP RST.
- In
Policy 1: shirudo.firewall (Ingress & egress blocking)
Use shirudo.firewall to block malicious external IPs, lock SSH down to your own IP address, restrict east-west lateral movement, lock down outbound egress with a default-drop allowlist, or log indicator hits without blocking.
Example A: Block an active exfiltration peer & C2 range (observe first, then enforce)
{
"kind": "shirudo.firewall",
"mode": "observe",
"selector_labels": {
"env": "prod"
},
"inbound": {
"default": "accept",
"deny_from": [
"203.0.113.45/32",
"198.51.100.0/24"
],
"deny": [
{ "proto": "tcp", "ports": [5432], "from": ["10.244.3.18/32"] }
]
},
"outbound": {
"default": "accept",
"deny_to": [
"169.254.169.254/32",
"198.51.100.44/32"
],
"deny": [
{ "proto": "tcp", "ports": [22], "to": ["10.0.0.0/8"] },
{ "proto": "tcp", "ports": [4444], "to": ["0.0.0.0/0"] }
],
"watch_to": [
"192.0.2.0/24"
]
}
}- Start with top-level
"mode": "observe". Matches increment Simulated & watched counters in Enforcement Metrics without dropping traffic (top-level"observe"always forces both directions into log-only observation). - Flip top-level
"mode"to"enforce"once verified (or set"mode": "enforce"with a per-direction"mode": "observe"on one direction to roll out ingress and egress independently).cyberdwill immediately drop matching packets and sever any existing TCP sockets to198.51.100.44,169.254.169.254, or port4444across the host and all containers/pods.
Example B: Strict default-drop egress with allowlist (Kubernetes namespace)
{
"kind": "shirudo.firewall",
"mode": "enforce",
"selector_labels": {
"cluster": "prod-eu"
},
"outbound": {
"mode": "enforce",
"default": "drop",
"k8s_namespace": "payments",
"k8s_pod_labels": {
"app": "checkout-api"
},
"allow": [
{ "proto": "tcp", "ports": [443], "to": ["10.96.0.0/12"] },
{ "proto": "tcp", "ports": [5432], "to": ["10.20.4.12/32"] },
{ "proto": "tcp", "ports": [443], "to": ["54.187.174.169/32"] }
],
"deny_to": [
"169.254.169.254/32"
]
}
}Under outbound.default: "drop", cyberd automatically keeps lifelines intact:
- Loopback (
lo) - SSH (
tcp/22, unless explicitly restricted viaallow_restricted_ssh: trueorallow_no_ssh: true) - The Helix Cyber Portal control-plane endpoint
- HA Kubernetes control-plane TCP ports (
2379,2380,6443,10250) and CNI overlay UDP ports (8472,51820,51821) - DNS (
udp/53andtcp/53) evaluated after explicitdeny/deny_torules so explicit DNS exfiltration blocks still win
Example C: Lock down SSH to your IP address (block everything else)
In the Helix Cyber Portal, open Defence → Policies → Quick firewall rules and choose either SSH-only lockdown (drops every inbound port except SSH from your IP) or SSH allowlist (restricts SSH to your IP while leaving other services open). The dialog detects your current IP automatically and provides a one-click My IP button on every inbound rule row.
Option 1 — Full inbound lockdown (block all inbound traffic except SSH from your IP):
{
"kind": "shirudo.firewall",
"mode": "enforce",
"allow_restricted_ssh": true,
"inbound": {
"default": "drop",
"allow": [
{
"proto": "tcp",
"ports": [22],
"from": ["203.0.113.10/32"],
"description": "Allowed SSH IP (all other inbound dropped)"
}
],
"log": true
},
"outbound": {
"default": "accept",
"log": true
}
}Option 2 — SSH-only allowlist (block all other SSH, keep web/app ports open):
{
"kind": "shirudo.firewall",
"mode": "enforce",
"allow_restricted_ssh": true,
"inbound": {
"default": "accept",
"allow": [
{
"proto": "tcp",
"ports": [22],
"from": ["203.0.113.10/32"],
"description": "Allowed SSH jump host / office IP"
}
],
"deny": [
{
"proto": "tcp",
"ports": [22],
"description": "Block all other SSH"
}
],
"log": true
}
}allow_restricted_ssh: trueexplicitly disables the default any-source SSH lifeline so only the CIDRs listed ininbound.allowcan reach TCP/22.- Both options evaluate
inbound.allowbeforeinbound.denyandinbound.default: "drop", and triggerSOCK_DESTROYagainst pre-existing unauthorized inbound sessions — terminating unauthorized SSH connections immediately while keeping your allowed IP's SSH session, outbound reply traffic, loopback, and Kubernetes lifelines alive. - As with all enforced policies,
cyberdguards the rollout with a 90-second automatic rollback if control-plane heartbeats fail.
shirudo.firewall field reference
| Field | Type | Description |
|---|---|---|
mode | "observe" | "enforce" | Top-level rollout mode. Setting "mode": "observe" forces both inbound and outbound into log-only observation (safety-first, overriding per-direction "enforce"). |
selector_labels | map<string, string> | Host labels selecting which enrolled nodes receive this bundle. |
inbound.mode / outbound.mode | "observe" | "enforce" | Optional per-direction mode when top-level mode is "enforce" or omitted — for example, enforce inbound while keeping outbound.mode: "observe". |
inbound.default / outbound.default | "accept" | "drop" | Default verdict when no rule matches. |
inbound.deny_from | string[] | Source IPs or CIDRs to block on ingress. |
outbound.deny_to | string[] | Destination IPs or CIDRs to block on egress (also triggers SOCK_DESTROY). |
outbound.watch_to | string[] | Destination IPs or CIDRs to log and count without dropping. |
inbound.allow / inbound.deny | Rule[] | Structured { proto, ports, from?, description? } tuples (proto: "tcp" or "udp", ports: number[], from: source string[] CIDRs; omit from for anywhere). |
outbound.allow / outbound.deny | Rule[] | Structured { proto, ports, to?, description? } tuples (proto: "tcp" or "udp", ports: number[], to: destination string[] CIDRs; omit to for anywhere). |
unit / cgroup | string | Optional systemd unit or cgroup v2 path scope for outbound rules. |
k8s_namespace / k8s_pod_labels | string / map | Optional Kubernetes workload scope. |
allow_no_ssh / allow_restricted_ssh | bool | Explicitly opt out of or restrict the automatic SSH lifeline. |
Policy 2: shirudo.sandbox (Workload isolation)
Use shirudo.sandbox to fence high-risk workloads (such as AI inference servers, Jupyter notebooks, or untrusted build runners) by restricting outbound egress, executable binaries, and writable paths.
{
"kind": "shirudo.sandbox",
"mode": "enforce",
"deny_cidrs": [
"169.254.169.254/32",
"10.0.0.0/8"
],
"sandboxes": [
{
"id": "sglang-inference",
"k8s_namespace": "ml-serving",
"k8s_pod_labels": {
"app": "sglang"
},
"mode": "enforce",
"exec_restrict": true,
"exec_paths": [
"/usr/bin/python3",
"/opt/venv/bin"
],
"deny_write_paths": [
"/etc",
"/usr/local/bin"
],
"egress_deny": [
"169.254.169.254/32",
"0.0.0.0/0"
]
}
]
}Kernel note for file/exec LSM enforcement: Network
egress_denyanddeny_cidrsenforce on any Linux 5.10+ kernel via eBPF cgroup hooks andnftables. Enforcingdeny_write_pathsandexec_restrictvia BPF LSM (lsm/file_open) requires thelsm=...,bpfkernel boot parameter; on kernels without BPF LSM enabled,cyberdautomatically falls back tokprobe/security_file_opentelemetry so alerts still fire.
Policy 3: shirudo.shield (HTTP path, sysctl & socket shields)
Use shirudo.shield to drop exploit requests at the kernel socket layer before a vulnerable application parses them, lock down /proc/sys writes, or block raw sockets inside workloads.
Example: Virtual patch an HTTP endpoint via cgroup_skb/ingress
{
"kind": "shirudo.shield",
"shield_id": "block-admin-rce-path",
"package": "sglang",
"mode": "enforce",
"hook": "cgroup_skb/ingress",
"k8s_namespace": "ml-serving",
"k8s_pod_labels": {
"app": "sglang"
},
"http_ports": [8000, 30000],
"http_deny_paths": [
"/update_weights_from_disk",
"/configure_logging",
"/admin/debug"
]
}Example: Block sysctl writes and raw sockets
{
"kind": "shirudo.shield",
"shield_id": "harden-runtime-sockets",
"mode": "enforce",
"hook": "cgroup/sysctl",
"unit": "docker.service",
"block_sysctl_writes": true
}{
"kind": "shirudo.shield",
"shield_id": "no-raw-sockets",
"mode": "enforce",
"hook": "lsm/socket_create",
"k8s_namespace": "prod",
"block_raw_sockets": true,
"block_socket_families": ["AF_PACKET"]
}Policy 4: shirudo.watch (Passive IOC & host file integrity)
Use shirudo.watch to monitor sensitive host files and threat-intel IPs without blocking traffic:
{
"kind": "shirudo.watch",
"selector_labels": {
"env": "prod"
},
"ips": [
"198.51.100.77",
"203.0.113.99"
],
"host_files": [
{ "path": "/etc/shadow", "write_only": false },
{ "path": "/etc/ssh/sshd_config", "write_only": true },
{ "path": "/root/.ssh/authorized_keys", "write_only": true }
]
}Operational caveats to keep in mind
| Scenario | Behavior |
|---|---|
| Existing TCP tunnels | Severed immediately by pre-established nftables drops + multi-namespace SOCK_DESTROY across host, Docker, and Kubernetes pods. |
| Existing UDP flows | cyberd's SOCK_DESTROY teardown sweep targets TCP; existing UDP streams stop on the very next packet via pre-established nftables drops (ff_output / ff_input / ff_forward). |
| Same-bridge L2 container-to-container | Layer 2 frames switched on the same host bridge bypass host ff_forward unless br_netfilter is enabled. However, cyberd still immediately severs existing same-bridge TCP tunnels via multi-namespace SOCK_DESTROY, and eBPF `cgroup/connect4 |
| BPF LSM hooks | lsm/file_open and lsm/socket_create enforcement require lsm=...,bpf in kernel boot args. Without it, kprobe observation runs automatically and all network/sysctl/HTTP hooks continue enforcing normally. |
Next steps
- Enforcement Metrics & Telemetry — Inspect simulated vs enforced drops and per-module kernel counters.
- Service Topology & Threat Overlays — Turn observed edges into firewall rules.