HelixML

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:

  1. New connection blocking (eBPF + atomic nftables)
    • cgroup/connect4 and cgroup/connect6 (including IPv4-mapped ::ffff:x.x.x.x sockets) return EPERM before a TCP SYN or connected UDP datagram leaves the kernel.
    • cgroup_skb/ingress and tc_ingress drop disallowed HTTP exploit paths and denied inbound L3/L4 traffic.
    • Atomic table inet helix_cyberd commits ff_input, ff_output, and ff_forward without touching Docker, kube-proxy, or CNI tables.
  2. Existing tunnel disruption (pre-established nftables + multi-netns SOCK_DESTROY)
    • In ff_output, enforced outbound.deny and outbound.deny_to rules are placed before ct state established,related accept. Under outbound.default: "drop", the established-state rule is restricted to ct direction reply so locally initiated outbound tunnels cannot bypass the default drop.
    • In ff_input, ct direction reply packets 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 then inbound.deny_from, inbound.allow, and inbound.deny evaluate before any blanket established-state accept (which is omitted entirely under inbound.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, cyberd runs NETLINK_SOCK_DIAG SOCK_DESTROY on 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 with ECONNABORTED / TCP RST.

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)

json
{
  "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). cyberd will immediately drop matching packets and sever any existing TCP sockets to 198.51.100.44, 169.254.169.254, or port 4444 across the host and all containers/pods.

Example B: Strict default-drop egress with allowlist (Kubernetes namespace)

json
{
  "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 via allow_restricted_ssh: true or allow_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/53 and tcp/53) evaluated after explicit deny / deny_to rules 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):

json
{
  "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):

json
{
  "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: true explicitly disables the default any-source SSH lifeline so only the CIDRs listed in inbound.allow can reach TCP/22.
  • Both options evaluate inbound.allow before inbound.deny and inbound.default: "drop", and trigger SOCK_DESTROY against 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, cyberd guards the rollout with a 90-second automatic rollback if control-plane heartbeats fail.

shirudo.firewall field reference

FieldTypeDescription
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_labelsmap<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_fromstring[]Source IPs or CIDRs to block on ingress.
outbound.deny_tostring[]Destination IPs or CIDRs to block on egress (also triggers SOCK_DESTROY).
outbound.watch_tostring[]Destination IPs or CIDRs to log and count without dropping.
inbound.allow / inbound.denyRule[]Structured { proto, ports, from?, description? } tuples (proto: "tcp" or "udp", ports: number[], from: source string[] CIDRs; omit from for anywhere).
outbound.allow / outbound.denyRule[]Structured { proto, ports, to?, description? } tuples (proto: "tcp" or "udp", ports: number[], to: destination string[] CIDRs; omit to for anywhere).
unit / cgroupstringOptional systemd unit or cgroup v2 path scope for outbound rules.
k8s_namespace / k8s_pod_labelsstring / mapOptional Kubernetes workload scope.
allow_no_ssh / allow_restricted_sshboolExplicitly 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.

json
{
  "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_deny and deny_cidrs enforce on any Linux 5.10+ kernel via eBPF cgroup hooks and nftables. Enforcing deny_write_paths and exec_restrict via BPF LSM (lsm/file_open) requires the lsm=...,bpf kernel boot parameter; on kernels without BPF LSM enabled, cyberd automatically falls back to kprobe/security_file_open telemetry 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

json
{
  "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

json
{
  "kind": "shirudo.shield",
  "shield_id": "harden-runtime-sockets",
  "mode": "enforce",
  "hook": "cgroup/sysctl",
  "unit": "docker.service",
  "block_sysctl_writes": true
}
json
{
  "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:

json
{
  "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

ScenarioBehavior
Existing TCP tunnelsSevered immediately by pre-established nftables drops + multi-namespace SOCK_DESTROY across host, Docker, and Kubernetes pods.
Existing UDP flowscyberd'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-containerLayer 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 hookslsm/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