Skip to content

fix(start-wrt): limit router access to the Admin profile - #4936

Open
Dominion5254 wants to merge 3 commits into
masterfrom
wrt/profile-router-access
Open

Dominion5254 wants to merge 3 commits into
masterfrom
wrt/profile-router-access

Conversation

@Dominion5254

@Dominion5254 Dominion5254 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Closes #4918.

Every Security Profile's firewall zone was created with input ACCEPT, so a device on any profile could open the router's web interface, connect over SSH, and use up the login rate limit that Admin devices share. Each profile's Allow-DHCP-DNS rule did nothing under that policy.

What changed

  • Only Admin manages the router. Zones of other profiles now use input REJECT. Two owned rules admit what their devices need from the router:
    • profile_<if>_dhcp_dns: DHCP, DHCPv6 (547), DNS, mDNS replies to the router's device-name lookups (5353), ICMP/ICMPv6, and the 9553/9554 listeners that TCP DNS and DNS UPDATE are diverted to.
    • profile_<if>_port_control: PCP (5351), SSDP (1900) and IGD (49001). The port-control server still decides per device and never lets one device see or change another's forwards.
  • Migration. RestrictProfileRouterAccess (append-only, idempotent) moves existing profile zones still on ACCEPT to REJECT and brings both rules up to date. A zone input changed in LuCI stays.
  • The public address still works from every profile.
    • What the WAN admits at the router's own address is now copied once per non-masquerading zone: hostname routes (the SNI demux), the HTTP→HTTPS redirect in front of them, and inbound WireGuard ports.
    • The copies are rebuilt wholesale through the existing _pp_hairpin mechanism used for IPv6 published-port copies.
    • They follow route, VPN server and profile changes.
    • Remote Access rules are not copied.
  • No way into the login page through a hostname route.
    • With Remote Access on and a hostname route on 443, an unmatched SNI falls back to the web interface.
    • That fallback now drops connections from any profile other than Admin. It checks each connection against the configured profile subnets, then against the router's live bridge addresses, so a profile being created, renumbered or removed stays blocked while its bridge catches up.
    • It drops every fallback connection while either of those can't be read.
    • Admin devices and clients outside the network are unaffected.
  • Docs: Security Profiles, Overview, Settings → Remote Access, a new FAQ troubleshooting entry, and Managed Switch. feat(start-wrt): connect a managed switch through a trunk port #4628 merged but has not shipped; its SSH-tunnel tip now says to use an Admin device.
  • Changelog: minor-security fragment, in release notes. StartWRT is already at 1.5.0 for a minor release.

Profiles seeded by #4825 inherit REJECT through create_config.

Verification

Verified on 1b23bdba0, then rebased onto master b7ed50e5f without conflicts. The review round's fallback-screen change (2fb800a2e) passed the tests below but was not benched.

  • make start-wrt-test passed on 2fb800a2e: 1028 startwrt-core and 37 uciedit tests, including the new ones:
    • zone input and rules for a created profile;
    • the migration, including a zone already on DROP and a second run that changes nothing;
    • copies across zones, excluding masquerading zones and Remote Access rules;
    • WireGuard port changes and removal carrying the copies;
    • the fallback screen, including a profile created and renumbered after the bridge addresses were cached, and an unreadable profile config.
  • cargo fmt --check and prettier passed.
  • K1 bench (wrt-bench), with synthetic clients on a Guest profile (VLAN 30) and on Admin:
    • Stock 1.5.0 baseline: the Guest client opened the web interface (HTTP and HTTPS) and SSH on 22 and 2222. This reproduces StartWRT profile zones set input ACCEPT #4918.
    • Upgrade: after deploy and reboot, the migration ran (record 18→19). The Guest zone became REJECT, and the nft chain held the expected sets.
    • From Guest on the branch:
      • DHCP lease and DHCPv6 lease (odhcp6c).
      • DNS over UDP and TCP, IPv4 and IPv6, and ping/ping6.
      • NAT-PMP/PCP and SSDP replies, and IGD HTTP.
      • Internet access works, and the Admin client stays unreachable.
      • The web interface, CA download and SSH were refused at every router address: the Guest gateway, the Admin gateway, the WAN IPv4, the WAN ULA addresses and link-local.
    • From Admin: every service unchanged.
    • Hostname route (added with X_START9_AddHostnameMapping, 443 → an Admin client):
      • From Guest, a matching SNI at the WAN IP reached the target.
      • From Guest, an unknown SNI or no SNI got EOF.
      • Admin and the WAN side (Remote Access behind-nat) got the web interface for an unknown SNI.
      • Port 80 at the WAN IP answered 307 to HTTPS from both profiles.
      • After the route was removed, all copies were gone and Guest was refused on WAN 80/443.
    • Inbound VPN on Admin:
      • A WireGuard client inside the Guest client completed a handshake at the WAN IP. The copied rule's counter took the 176-byte initiation.
      • The web interface and SSH opened through the tunnel.
      • Deleting the server removed the copies.
    • New profile on the branch: a profile created on the branch got REJECT, both rules, and the hostname-route and VPN copies. Deleting it removed all of them from UCI and nft.
    • bench.sh smoke passed.

Not exercised: a hostname route registered by a real StartOS server (os-bench was unreachable), and the mDNS reply path to the router's lookups.

Every profile zone was created with input ACCEPT, so a device on any
profile reached the router's web interface, SSH and every other service
on it. The Allow-DHCP-DNS rule each profile carried had no effect.

Zones of profiles other than Admin now reject input. Their rules admit the
services those devices need from the router: DHCP, DHCPv6, DNS (including
TCP DNS and DNS updates diverted to the daemon's 9553/9554 listeners),
mDNS replies to the router's device-name lookups, ICMP, and PCP/UPnP. A
migration moves existing profile zones still on ACCEPT to REJECT and brings
their rules up to date; a zone input changed in LuCI stays.

Hostname routes, the HTTP redirect in front of them, and inbound VPN
listen ports are admitted from the WAN at the router's own address, so
the new policy would have cut every profile off from them at the public
address. Their WAN rules are now copied once per non-masquerading zone,
rebuilt wholesale like the IPv6 published-port copies. Remote Access rules
are not copied. When Remote Access is on and a hostname route holds 443,
unmatched SNI falls back to the web interface; that fallback now drops
connections from LAN bridges other than Admin's.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Keep the SNI fallback closed across profile topology changes (projects/start-wrt/backend/ctrl/src/port_control.rs:266–286). With Remote Access enabled and a hostname route holding 443, admits_ui_fallback admits any peer absent from lan_addrs(). That list is cached for 30 seconds, and profile creation/renumbering does not invalidate it. If a new or renumbered non-Admin profile becomes reachable before that snapshot expires, its copied SNI rule admits the connection and an unknown/no SNI reaches the router's login page. An ip command/JSON failure also becomes an empty list and admits every peer. This leaves the Admin-only management guarantee, including protection of the shared login rate limit, unenforced on these paths.

The proposal reads configured profile networks through the existing reservations::profile_networks owner before considering a peer external, uses an uncached live lookup for addresses outside those networks, and drops fallback connections when policy/address reads fail. It records the topology-change invariant at the admission owner and adds regression coverage for profile creation/renumbering with an incomplete bridge cache and unreadable policy/address data. The shared live-address reader also keeps the existing cached lookup for non-authorization callers. Redundant comments beside the changed helpers are removed.

The reviewed head merges cleanly with origin/master. I also traced the service exceptions, migration, public-service copies, and profile/VPN/SNI lifecycle callers; no other blocking findings. No builds or tests were run in review; the proposal and its tests are unexecuted for the author to verify. CI compilation and test jobs were still pending when inspected.

Proposed changes: f7ef5b2...proposal/4936

To adopt the proposal, cherry-pick it onto your branch rather than merging or pulling it, so the PR's head stays your own commit:

git fetch https://github.com/Start9Labs/start-technologies.git proposal/4936
git cherry-pick f7ef5b22dca809032ebcb36344596d92a5ac405d..FETCH_HEAD

If your branch has moved since f7ef5b2, resolve any conflicts the cherry-pick reports, or apply the changes your own way. Then push and say so in a comment.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

helix-white and others added 2 commits November 24, 2026 22:46
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
…adable

An absent `network` config parses as empty, so the test reached the live
`ip -j addr show` read and passed only where `ip` is missing, as in the
builder image. A host `cargo test` with iproute2 admitted the peer and
failed. A directory in place of `network` fails the policy read itself.
@Dominion5254

Copy link
Copy Markdown
Member Author
  • [P1] SNI fallback across topology changes: adopted, cherry-picked unchanged as 89de416.
    • Your creation/renumber test fails against a copy of the previous admits_ui_fallback and passes against the new code.
    • One fix on top, 2fb800a: ui_fallback_rejects_an_unreadable_profile_policy passed only where ip is missing. Its empty root parses as an empty config, so the call fell through to the live ip -j addr show. That errors in the builder image, but with iproute2 on the host it returned Ok(true) and the test failed. The test now puts a directory where network should be, so the config read itself fails.
    • make start-wrt-test passes (1028 + 37).
    • Not benched this round.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 2fb800a.

Since my review of f7ef5b2, my proposal landed unchanged as 89de416 (same tree as proposal/4936). 2fb800a fixes a flaw in the ui_fallback_rejects_an_unreadable_profile_policy test I proposed: with no network file the config parses as empty, so the test reached the host's ip -j addr show and passed only where ip is missing. A directory in place of network now makes the profile read itself fail, which is what the test is named for. My earlier point is resolved: the fallback consults the configured profile subnets on every connection, so a new or renumbered profile is screened before its bridge address appears. The head merges cleanly into origin/master (b7ed50e). I re-read the whole diff on this head, not only the delta, and found no correctness regressions.

Brief

Summary

  • Devices on any profile other than Admin can no longer reach the router's own services. Their firewall zones get input REJECT; Admin keeps ACCEPT. Two owned rules per profile (profile_<if>_dhcp_dns and profile_<if>_port_control) admit what devices need: DHCP and DHCPv6, DNS (including the 9553/9554 listeners that TCP DNS and DNS UPDATE are diverted to), mDNS replies on 5353, ICMP and ICMPv6, and PCP, SSDP and IGD. From another profile, router.lan refuses the connection.
  • The appended migration RestrictProfileRouterAccess moves existing profile zones still on ACCEPT to REJECT, keeps any other input a user chose (a DROP set in LuCI stays), and rewrites both owned rules. New profiles get the same through create_config. Editing a profile keeps its zone's input.
  • Rules the WAN uses to admit traffic to the router's public IPv4 address are copied into every non-masquerading zone: hostname routes on the SNI demux, the HTTP→HTTPS redirect in front of them, and inbound WireGuard ports. Devices on any profile therefore reach those as they would from the Internet. Remote Access rules are not copied. sync_hairpin_rules rebuilds the copies wholesale. It was the IPv6-only sync_v6_hairpin_rules, and now also runs on SNI reconciliation and WireGuard rule changes.
  • With Remote Access on and a hostname route holding 443, an unmatched or missing SNI falls back to the web interface. That fallback now passes through a screening task that drops peers on any non-Admin profile subnet. It checks the subnets configured in network and startwrt first, then the router's live br-* addresses, which cover a profile being removed or renumbered until netifd catches up. If the profile config can't be read, every fallback connection is dropped. If the live addresses can't be read, connections from outside the profile subnets are dropped. The description says either failure drops every fallback connection, but Admin devices are decided from configuration and still get in. WAN-side clients and Admin devices are otherwise unaffected.
  • Docs (Security Profiles, Overview, Settings → Remote Access, FAQ, Managed Switch) and a minor-security changelog fragment with release-notes: true.

Implementation diff: +241 / −40 lines in 5 files (excludes lockfiles, tests, docs, release notes, and changelog).

Approach

  • Root cause: rewrite_firewall created every profile zone with input ACCEPT, so the existing Allow-DHCP-DNS-* rule did nothing and every router service was open to every profile. The PR fixes the zone policy rather than gating individual services.
  • The copies reuse the _pp_hairpin copy mechanism already used for IPv6 published ports. The owned rules reuse reconcile_owned. Configured subnets come from reservations::profile_networks, as in devices.rs.
  • The screen sits in StartWRT, between the shared start-core SNI demux and the HTTPS listener. The demux's fallback source policy (FallbackSource: any address, or private addresses only) is shared with StartTunnel, so the PR leaves it unchanged.
  • Exposure: the copied 443 and 80 rules are pinned to the WAN IPv4 address. At that address the HTTP listener always redirects to HTTPS, because it decides by destination address, not Host. Its gate opens before the rule and its copies are written, so the port-80 copy never serves the UI over HTTP. WireGuard copies carry no destination address and admit the WireGuard port at every router address; WireGuard authenticates every peer there. The SNI demux is IPv4-only, so no copy opens an IPv6 path to the UI.

Decision

  • Every fallback connection costs a UCI read of network and startwrt. A connection from outside the configured profile subnets also starts an ip -j addr show process; in practice that is every WAN-side Remote Access client. The screen handles one connection at a time from a 128-connection queue, the same size as the demux's own handoff.
    • Benefit: the live-bridge check stays exact while a removed or renumbered profile's bridge is torn down.
    • Cost: with Remote Access set to Always, anyone on the Internet can make the router start one process per connection by sending an unmatched or empty SNI. A burst of those queues legitimate fallback connections behind it. Behind NAT, the fallback admits only private source addresses, which limits this to the upstream network. Hostname routes and LAN access are unaffected. Not measured.
    • Alternative: I proposed this uncached read in the previous round. The live addresses could instead go through the existing 30-second lan_addrs() cache, or a refresh floor like http_redirect's 5 seconds. Either removes the per-connection process. The configured-subnet check would still cover every current profile. The cost: a profile created and then removed or renumbered within that period could go unscreened while its bridge is torn down.
    • Question: is one process per fallback connection acceptable here, or should this read go through a cache?

Neighbors

  • Draft #4835 moves inbound VPN clients out of their profile's /24 onto a /24 per server, outside the profile's bridge. The screen knows only profile subnets: configured interfaces and live br-* addresses. Once both land, a client of a non-Admin inbound VPN would pass as a WAN-side peer and reach the login page through the fallback. Whichever merges second has to give the screen the inbound VPN subnets and their profiles. #4828, which #4835 waits on, has merged.
  • #4691, #4840, #4882 and #4885 also append to MIGRATIONS. Whichever merges later goes after this entry, without reordering.

Testing

I ran no builds or tests; this review is read-only. Evidence recorded on the PR:

  • On the head 2fb800a, the author reports make start-wrt-test passing: 1028 startwrt-core and 37 uciedit tests. They cover:
    • zone input and rules for a created profile;
    • the migration, including a kept DROP zone and an idempotent second run;
    • copies across zones and their exclusions;
    • WireGuard port changes and removal carrying the copies;
    • the fallback screen, for a profile created and renumbered after the bridge addresses were cached, and for an unreadable profile config. The author reports the created-and-renumbered test fails against the previous admits_ui_fallback.
  • The author's K1 bench ran on 1b23bdba0, the head before this review round:
    • The stock 1.5.0 baseline reproduced #4918.
    • After the upgrade the migration ran. A Guest client kept DHCP, DHCPv6, DNS, port control and Internet access, while the web interface, CA download and SSH were refused at every router address. Admin was unchanged.
    • From Guest, hostname routes, the port-80 redirect and an Admin inbound VPN worked at the WAN address. Their copies followed route, VPN-server and profile creation and deletion.
  • Not exercised on a router:
    • the screen as it now stands, with the configured-subnet check and the uncached ip read for WAN-side peers;
    • a hostname route registered by a real StartOS server;
    • the mDNS reply path to the router's lookups.
  • CI on this head was still running StartWRT Tests, Build riscv64 binary, Generated Bindings & MCP Catalog, and the start-core and rpc-toolkit test jobs when reviewed. Formatting & Lockfiles and Changelog fragments & versions had passed.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StartWRT profile zones set input ACCEPT

2 participants