routeros: BGP hardening (input filter, route cap, TCP MD5 key with Cilium) #125

Open
opened 2026-11-17 02:12:59 +00:00 by ginjiruu · 2 comments
Owner

Follow-up to the cutover (#73). The output-filter half shipped with #145 (PR #152: reject-all chain bgp-out on every connection, proven on the lab CHR pair and live in prod with advertisements 0). What remains here: input filter, route cap, TCP MD5, and the port-179 narrowing.

Gaps, most important first

  1. No input filter. routeros/modules/router/bgp.tf says it: RouterOS 7 accepts every received route when no input filter is set. If mini announced 0.0.0.0/0, 10.15.1.0/24 or a /32 for OpenBao (from a Cilium misconfiguration or a spoofed peer), both routers would install it. Since #145 this matters twice as much: each peer now also runs a v6 session and can push fdd5:... routes.
  2. No route cap. Nothing limits how many routes a peer may send, in either family (input.limit-process-routes-ipv4 / -ipv6).
  3. No TCP MD5 key. Anyone holding L2 position on a peer's segment (VLAN 1 for mini, VLAN 20 for the thinks) can spoof the configured peer address and reach TCP 179 as that peer.
  4. Port 179 is open to the whole management networks, not just the peers. Verified live 2026-11-18: MGMT-ACCESS = vlan10-mgmt + vrrp10, vlan30-trusted + vrrp30, bridge + vrrp1 (the legacy LAN), and in-mgmt accepts every input connection from it before any drop. So any device landing on the legacy LAN or VLAN 30 can open TCP 179 (RouterOS still refuses a session unless the source matches a configured peer). The VLAN 20 thinks are NOT broadly open: they pass only through the per-peer /32 accepts in-bgp-c1-think-0{1,2,3}. No cameras are involved: the three addresses in the frigate template (10.15.1.239/.60/.132) answer nothing (no ARP, no leases, no ping, both routers, 2026-11-18) and VLAN 30 carries only the workstation. The original "cameras ride in trusted" premise was inherited from that stale template and is removed from this issue.

Plan

Commit 1: route filter and cap (routeros/modules/router/bgp.tf)

  • Input filter chain per peer, an allowlist from modules/site as a per-peer field (for example accept = [{ prefix, len }]), covering both families:
    • mini-01: its LB pool (/32s) and PodCIDR if kept (see Decide first), plus whatever it announces over v6 when mini gets v6;
    • each c1 think: its node pod net 10.30.12<N>.0/24 and fdd5:c8ef:2fa0:4<N>::/64.
  • input.filter = <peer>-in and input.limit-process-routes-ipv4 / -ipv6 (a few hundred) on routeros_routing_bgp_connection, on the -v6 connections too.
  • Check the RouterOS 7 rule syntax (dst-len == 32 vs dst-len in 32..32) on the CHR sim pair (routeros/sim), and confirm in the gate that all routes are still learned.

Commit 2: TCP MD5 key, router side and Cilium side together

  • New key in OpenBao secret/routeros-secrets (for example bgp_md5_<peer>), read through the existing ESO path into the device roots, then tcp_md5_key on the connection (both the v4 and the -v6 connection of each peer share the key).
  • flux-clusters: an ExternalSecret for the same key into a Secret in kube-system with key password, and authSecretRef on the CiliumBGPPeerConfig (c1 thinks today; mini's cilium-peer when mini joins).
  • Both ends must change together. If only one side has the key, the session stays down until the other matches, and the routers lose the LoadBalancer and pod routes. Merge both PRs in one window.

Commit 3 (with the LAN zone rework): narrow port 179 to the peers

  • mini-01 has no net field in modules/site today, so its session "rides in-mgmt" (comment in firewall.tf): the first step is giving it a per-peer accept like the thinks have.
  • A drop for tcp/179 from MGMT-ACCESS sources that are not configured peers, placed before in-mgmt, is the one safe sliver of this work: it does not touch the REST/SSH/Winbox path, so the #74 lockout rule (management accept before any drop) is not at risk.
  • The rest — retiring the legacy-LAN blanket from MGMT-ACCESS — is the zone rework itself, gated on the c2 rebuild (address inventory, "hardening is iac#125, gated on c2").

Decide first

  • PodCIDR advertisement. Cilium on mini announces PodCIDR (10.44.0.0/24) as well as the LoadBalancer IPs, so the LAN can reach pods directly and skip Services. If nothing needs that, drop PodCIDR from the CiliumBGPAdvertisement and allow only the LB pool in the filter.

Notes

  • TCP-AO (RFC 5925) is the successor to TCP MD5. As far as we know RouterOS doesn't support it, and Cilium's BGP only offers MD5, so MD5 is the option both ends speak.
  • These are directly connected eBGP peers, so the default TTL of 1 is already right. No multihop. For the v6 sessions, the input6 pins added in #145 already restrict who may dial per session address; MD5 is about authenticating the dialer.
  • Side finding while verifying gap 4: the generic-templates/frigate HelmRelease still points at the three dead RTSP sources with plaintext creds in git (the inventory flagged that cleanup too). If the cameras are gone for good, frigate should be deleted with them.
  • Refs #73, #118, #145 (v6 sessions + output filter, done). Cilium peer move: flux-clusters#1706; c1 v6 peers: flux-clusters#1726.

Search keywords: TODO bgp filter md5 tcp-md5-key authSecretRef hardening route-limit.

Follow-up to the cutover (#73). The output-filter half shipped with #145 (PR #152: reject-all chain `bgp-out` on every connection, proven on the lab CHR pair and live in prod with advertisements 0). What remains here: input filter, route cap, TCP MD5, and the port-179 narrowing. ## Gaps, most important first 1. **No input filter.** `routeros/modules/router/bgp.tf` says it: RouterOS 7 accepts every received route when no input filter is set. If mini announced `0.0.0.0/0`, `10.15.1.0/24` or a /32 for OpenBao (from a Cilium misconfiguration or a spoofed peer), both routers would install it. Since #145 this matters twice as much: each peer now also runs a v6 session and can push `fdd5:...` routes. 2. **No route cap.** Nothing limits how many routes a peer may send, in either family (`input.limit-process-routes-ipv4` / `-ipv6`). 3. **No TCP MD5 key.** Anyone holding L2 position on a peer's segment (VLAN 1 for mini, VLAN 20 for the thinks) can spoof the configured peer address and reach TCP 179 as that peer. 4. **Port 179 is open to the whole management networks, not just the peers.** Verified live 2026-11-18: `MGMT-ACCESS` = vlan10-mgmt + vrrp10, vlan30-trusted + vrrp30, bridge + vrrp1 (the legacy LAN), and `in-mgmt` accepts every input connection from it before any drop. So any device landing on the legacy LAN or VLAN 30 can open TCP 179 (RouterOS still refuses a session unless the source matches a configured peer). The VLAN 20 thinks are NOT broadly open: they pass only through the per-peer /32 accepts `in-bgp-c1-think-0{1,2,3}`. No cameras are involved: the three addresses in the frigate template (10.15.1.239/.60/.132) answer nothing (no ARP, no leases, no ping, both routers, 2026-11-18) and VLAN 30 carries only the workstation. The original "cameras ride in trusted" premise was inherited from that stale template and is removed from this issue. ## Plan ### Commit 1: route filter and cap (routeros/modules/router/bgp.tf) - Input filter chain per peer, an allowlist from `modules/site` as a per-peer field (for example `accept = [{ prefix, len }]`), covering both families: - mini-01: its LB pool (/32s) and PodCIDR if kept (see Decide first), plus whatever it announces over v6 when mini gets v6; - each c1 think: its node pod net `10.30.12<N>.0/24` and `fdd5:c8ef:2fa0:4<N>::/64`. - `input.filter = <peer>-in` and `input.limit-process-routes-ipv4` / `-ipv6` (a few hundred) on `routeros_routing_bgp_connection`, on the `-v6` connections too. - Check the RouterOS 7 rule syntax (`dst-len == 32` vs `dst-len in 32..32`) on the CHR sim pair (routeros/sim), and confirm in the gate that all routes are still learned. ### Commit 2: TCP MD5 key, router side and Cilium side together - New key in OpenBao `secret/routeros-secrets` (for example `bgp_md5_<peer>`), read through the existing ESO path into the device roots, then `tcp_md5_key` on the connection (both the v4 and the `-v6` connection of each peer share the key). - flux-clusters: an ExternalSecret for the same key into a Secret in `kube-system` with key `password`, and `authSecretRef` on the `CiliumBGPPeerConfig` (c1 thinks today; mini's `cilium-peer` when mini joins). - Both ends must change together. If only one side has the key, the session stays down until the other matches, and the routers lose the LoadBalancer and pod routes. Merge both PRs in one window. ### Commit 3 (with the LAN zone rework): narrow port 179 to the peers - mini-01 has no `net` field in `modules/site` today, so its session "rides in-mgmt" (comment in `firewall.tf`): the first step is giving it a per-peer accept like the thinks have. - A drop for tcp/179 from MGMT-ACCESS sources that are not configured peers, placed before `in-mgmt`, is the one safe sliver of this work: it does not touch the REST/SSH/Winbox path, so the #74 lockout rule (management accept before any drop) is not at risk. - The rest — retiring the legacy-LAN blanket from MGMT-ACCESS — is the zone rework itself, gated on the c2 rebuild (address inventory, "hardening is iac#125, gated on c2"). ## Decide first - **PodCIDR advertisement.** Cilium on mini announces `PodCIDR` (10.44.0.0/24) as well as the LoadBalancer IPs, so the LAN can reach pods directly and skip Services. If nothing needs that, drop `PodCIDR` from the `CiliumBGPAdvertisement` and allow only the LB pool in the filter. ## Notes - TCP-AO (RFC 5925) is the successor to TCP MD5. As far as we know RouterOS doesn't support it, and Cilium's BGP only offers MD5, so MD5 is the option both ends speak. - These are directly connected eBGP peers, so the default TTL of 1 is already right. No multihop. For the v6 sessions, the input6 pins added in #145 already restrict *who* may dial per session address; MD5 is about *authenticating* the dialer. - Side finding while verifying gap 4: the `generic-templates/frigate` HelmRelease still points at the three dead RTSP sources with plaintext creds in git (the inventory flagged that cleanup too). If the cameras are gone for good, frigate should be deleted with them. - Refs #73, #118, #145 (v6 sessions + output filter, done). Cilium peer move: flux-clusters#1706; c1 v6 peers: flux-clusters#1726. Search keywords: TODO bgp filter md5 tcp-md5-key authSecretRef hardening route-limit.
Author
Owner

Re-scoped after #145: the reject-all output chain shipped there (PR #152), so this issue is now input filter + route cap + MD5 + port 179. The v6 sessions from #145 are in scope for all of them, and each peer connection now exists twice (v4 and -v6).

Re-scoped after #145: the reject-all output chain shipped there (PR #152), so this issue is now input filter + route cap + MD5 + port 179. The v6 sessions from #145 are in scope for all of them, and each peer connection now exists twice (v4 and -v6).
Author
Owner

Camera premise re-verified and removed (2026-11-18, both routers): no ARP entries, no DHCP leases, no ping replies for 10.15.1.239/.60/.132; VLAN 30 carries only the workstation; the legacy LAN carries mini-01, the routers and one dormant non-camera device. The claim traced back to the checked-in frigate helmrelease RTSP config, not to live state. Gap 4 corrected: the broad 179 reach is only the MGMT-ACCESS networks (VLAN 10 + VLAN 30 + legacy LAN); VLAN 20 peers already pass only via per-peer /32 accepts.

Camera premise re-verified and removed (2026-11-18, both routers): no ARP entries, no DHCP leases, no ping replies for 10.15.1.239/.60/.132; VLAN 30 carries only the workstation; the legacy LAN carries mini-01, the routers and one dormant non-camera device. The claim traced back to the checked-in frigate helmrelease RTSP config, not to live state. Gap 4 corrected: the broad 179 reach is only the MGMT-ACCESS networks (VLAN 10 + VLAN 30 + legacy LAN); VLAN 20 peers already pass only via per-peer /32 accepts.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/iac#125
No description provided.