Repository navigation
fix(start-wrt): limit router access to the Admin profile - #4936
Dominion5254 wants to merge 3 commits into
Conversation
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
left a comment
There was a problem hiding this comment.
[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_HEADIf 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-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.
|
helix-white
left a comment
There was a problem hiding this comment.
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 keepsACCEPT. Two owned rules per profile (profile_<if>_dhcp_dnsandprofile_<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.lanrefuses the connection. - The appended migration
RestrictProfileRouterAccessmoves existing profile zones still onACCEPTtoREJECT, keeps any other input a user chose (aDROPset in LuCI stays), and rewrites both owned rules. New profiles get the same throughcreate_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_rulesrebuilds the copies wholesale. It was the IPv6-onlysync_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
networkandstartwrtfirst, then the router's livebr-*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-securitychangelog fragment withrelease-notes: true.
Implementation diff: +241 / −40 lines in 5 files (excludes lockfiles, tests, docs, release notes, and changelog).
Approach
- Root cause:
rewrite_firewallcreated every profile zone withinput ACCEPT, so the existingAllow-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_hairpincopy mechanism already used for IPv6 published ports. The owned rules reusereconcile_owned. Configured subnets come fromreservations::profile_networks, as indevices.rs. - The screen sits in StartWRT, between the shared
start-coreSNI 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
networkandstartwrt. A connection from outside the configured profile subnets also starts anip -j addr showprocess; 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 likehttp_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-testpassing: 1028startwrt-coreand 37uciedittests. They cover:- zone input and rules for a created profile;
- the migration, including a kept
DROPzone 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
ipread for WAN-side peers; - a hostname route registered by a real StartOS server;
- the mDNS reply path to the router's lookups.
- the screen as it now stands, with the configured-subnet check and the uncached
- 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
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'sAllow-DHCP-DNSrule did nothing under that policy.What changed
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.RestrictProfileRouterAccess(append-only, idempotent) moves existing profile zones still onACCEPTtoREJECTand brings both rules up to date. A zone input changed in LuCI stays._pp_hairpinmechanism used for IPv6 published-port copies.minor-securityfragment, in release notes. StartWRT is already at 1.5.0 for a minor release.Profiles seeded by #4825 inherit
REJECTthroughcreate_config.Verification
Verified on
1b23bdba0, then rebased onto masterb7ed50e5fwithout conflicts. The review round's fallback-screen change (2fb800a2e) passed the tests below but was not benched.make start-wrt-testpassed on2fb800a2e: 1028startwrt-coreand 37uciedittests, including the new ones:DROPand a second run that changes nothing;cargo fmt --checkand prettier passed.wrt-bench), with synthetic clients on a Guest profile (VLAN 30) and on Admin:REJECT, and thenftchain held the expected sets.X_START9_AddHostnameMapping, 443 → an Admin client):behind-nat) got the web interface for an unknown SNI.REJECT, both rules, and the hostname-route and VPN copies. Deleting it removed all of them from UCI andnft.bench.sh smokepassed.Not exercised: a hostname route registered by a real StartOS server (
os-benchwas unreachable), and the mDNS reply path to the router's lookups.