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.
This commit is contained in:
Lance Walters 2026-11-27 00:09:11 -05:00
commit 181266d7d4
5 changed files with 70 additions and 26 deletions

View file

@ -21,12 +21,26 @@ exactly one node.
| siriussec (10.10.0.2) — **load bearing** | nftables table `inet internal_gw`, loaded by a oneshot unit (same pattern as `k8s-api-firewall.service`) | `siriussec-internal-gw.nft`, `internal-gw-firewall.service` |
| rpi (10.10.0.1) — **inert guard** | ufw rules inserted above the `allow from 192.168.1.0/24` catch-all | `rpi-ufw-internal-gw.sh` |
Effective policy for `:8081` (Grafana), `:8084` (Hubble UI) and `:8085`
(Metabase):
Effective policy for `:8080` (the `public` gateway — Cloudflare tunnel origin),
`:8081` (Grafana), `:8084` (Hubble UI), `:8085` (Metabase) and `:8086`/`:8087`
(Customer 1 lab replica):
**accept from 10.10.0.0/24 and 10.244.0.0/16, accept on lo, drop everything
else** (LAN, tailscale, public). Envoy binds every listener on `0.0.0.0`, so a
new internal listener port is a LAN exposure until it is added here. The
accept rules carry `counter`s: `nft list table inet internal_gw` shows packets
new listener port is a LAN exposure until it is added here.
**`:8080` is in the WG-only set too, and that is deliberate** (2026-11-27,
audit finding F2). `gateway-system/public` has no hostname restriction
(`allowedRoutes.namespaces.from: All`), so before this the LAN could
`curl -H 'Host: forgejo.siriusdevops.com' http://192.168.1.179:8080/` and get
Forgejo over plain HTTP — no Cloudflare TLS, WAF, rate limits or bot
protection, and credentials on the wire inside 192.168.1.0/24. The only
legitimate client is `cloudflared` on rpi, which connects **over the mesh**
(`ss` on siriussec shows `10.10.0.1:* -> 10.10.0.2:8080 ESTABLISHED`), so the
`10.10.0.0/24` accept covers production. Do not treat the public gateway as
LAN-reachable just because it is "public": it is public *through Cloudflare*,
and the tunnel origin is on the overlay.
The accept rules carry `counter`s: `nft list table inet internal_gw` shows packets
that reached the host and were allowed, which is the only way to tell "the
firewall accepted it and Envoy answered" from "the client never got there" —
rpi's ufw accept rules read 0 packets while requests to `10.10.0.1:8081` were
@ -63,10 +77,17 @@ ufw status | grep -E '8081|8084|8085'
Negative test from the LAN must be a timeout (DROP), never 200:
```bash
curl -m 3 -sS -o /dev/null -w '%{http_code}\n' http://192.168.1.179:8080/ # empty/000
curl -m 3 -sS -o /dev/null -w '%{http_code}\n' http://192.168.1.179:8081/ # empty/000
curl -m 3 -sS -o /dev/null -w '%{http_code}\n' http://192.168.1.125:8081/ # empty/000
```
Positive test from the mesh must still be 200 (this is what cloudflared does):
```bash
curl -m 5 -sS -o /dev/null -w '%{http_code}\n' -H 'Host: siriusdevops.com' http://10.10.0.2:8080/
```
When a new internal listener port is added, add it to the `tcp dport { … }` set
in `siriussec-internal-gw.nft` and to `PORTS` in `rpi-ufw-internal-gw.sh` (which
inserts one deny for the port plus mesh and pod-CIDR allows above the LAN