homek8s/infrastructure/networking/internal/host-firewall/siriussec-internal-gw.nft
Lance Walters 181266d7d4 fix(networking): make the public gateway :8080 WireGuard-only
Finding F2 of the 2026-11-27 cluster netsec audit: cilium-envoy on siriussec
binds gateway-system/public on 0.0.0.0:8080, so anyone on 192.168.1.0/24 could
`curl -H 'Host: forgejo.siriusdevops.com' http://192.168.1.179:8080/` and get
Forgejo (and every public site) over plain HTTP — no Cloudflare TLS, WAF, rate
limits or bot protection, and credentials on the wire inside the LAN. Live:
200 / 14609 B before this change.

The `internal_gw` nft table that already makes 8081/8084-8087 WG-only simply
did not list 8080. Add it to all three rules (lo, mesh+pods, drop), and to the
rpi ufw guard so a future `gateway=true` relabel on the Pi cannot re-open it.

Nothing legitimate needs the LAN path: cloudflared runs on rpi and connects to
10.10.0.2:8080 from 10.10.0.1 over the mesh (`ss` on siriussec shows
`10.10.0.1:* -> 10.10.0.2:8080 ESTABLISHED`), which the 10.10.0.0/24 accept
covers. 10.244.0.0/16 stays accepted for in-cluster probes.

Verified both polarities: LAN 192.168.1.179:8080 -> timeout/DROP (from two
vantage points), mesh 10.10.0.2:8080 -> 200 for all five public hostnames, and
all five public URLs still 200 through Cloudflare.
2026-11-27 00:09:14 -05:00

52 lines
2.4 KiB
Text

#!/usr/sbin/nft -f
# Gateway listener host firewall on siriussec: the listeners that must answer
# the WireGuard mesh and the pod network only, never the LAN.
#
# Ports and who they serve:
# 8080 public — Cloudflare tunnel origin (cloudflared runs on rpi)
# 8081 internal — Grafana
# 8084 internal — Hubble UI
# 8085 internal — Metabase
# 8086 internal — Customer 1 lab Odoo
# 8087 internal — Customer 1 lab Metabase
#
# Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so every
# listener is open on the LAN interface the moment the Gateway is programmed.
# This table makes them answer only from the WireGuard mesh and the pod network.
# DROP (not reject) so a LAN scan sees a timeout, not a port that tells you
# something is listening.
#
# 8080 is in this set on purpose. `gateway-system/public` serves the public
# hostnames and used to answer 192.168.1.0/24 over plain HTTP; a spoofed
# `Host:` header then served Forgejo and every public site without Cloudflare's
# TLS, WAF, rate limits or bot protection, and put credentials on the wire
# inside the LAN. The only legitimate client of :8080 is the tunnel origin —
# cloudflared on rpi (10.10.0.1), which connects to 10.10.0.2:8080 over the
# WireGuard mesh — so the saddr rule below covers it. Nothing may reach :8080
# from the LAN.
#
# Adding a listener: add its port to the set in all three rules below,
# reinstall this file, then
# `systemctl reload-or-restart internal-gw-firewall.service`. The same list
# must also be added to the rpi ufw rules (rpi-ufw-internal-gw.sh).
#
# Loaded by internal-gw-firewall.service on siriussec. `destroy` (not `delete`)
# so re-running the unit REPLACES the table instead of appending a second copy
# of the rules, and does not fail when the table does not exist yet.
destroy table inet internal_gw
table inet internal_gw {
chain input {
type filter hook input priority filter; policy accept;
# local process / kubelet probes
tcp dport { 8080, 8081, 8084, 8085, 8086, 8087 } iifname "lo" counter accept
# WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes;
# 10.10.0.1 = the cloudflared tunnel origin) and the pod network
# (in-cluster probes, gateway to service traffic)
tcp dport { 8080, 8081, 8084, 8085, 8086, 8087 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter accept
# everything else: LAN, tailscale, public
tcp dport { 8080, 8081, 8084, 8085, 8086, 8087 } counter drop
}
}