Repository navigation
fix(start-os): stop cross-site calls to the setup, init and diagnostic servers - #4491
Conversation
…c servers These servers have no authentication and used the shared CORS middleware, which reflects any Origin with credentials allowed and approves every preflight. rpc-toolkit also parsed the body as JSON whatever the Content-Type. A public page opened by someone on the LAN could therefore read setup.disk.list and setup.get-pubkey and call setup.execute or the diagnostic actions while the device was in one of these modes. - Drop the CORS middleware from these three servers, so cross-origin reads and preflights fail. - Require Content-Type: application/json on their /rpc, so a "simple" text/plain or form POST cannot run a method without a preflight. - Serve them only when the Host is an IP address, localhost, or a .local name, so DNS rebinding cannot make the requests same-origin. The authenticated main, registry and tunnel servers keep their CORS behaviour: their credentials travel only in request headers, so a cross-site request carries none.
Helix-Harness: pi Helix-Model: openai-codex/gpt-6.1-sol
|
Cross-review requested after establishing Helix implementation ownership with an empty takeover commit. The original code and author commit are unchanged. The earlier request could not be routed because this human-authored PR had no Helix implementer; please review the full change against master. |
helix-white
left a comment
There was a problem hiding this comment.
Reviewed the full diff at bf9aeb5 against master. It merges cleanly (git merge-tree exits 0).
What I checked:
- Callers of
RequireJson: the AngularHttpServiceposts object bodies, which HttpClient sends asapplication/json. The CLI'sCallRemote<SetupContext|InitContext|DiagnosticContext>paths all go throughsignature::call_remote_with_client, which sendsapplication/json. It does not use rpc-toolkit'scall_remote_http, which sendsapplication/cborunder the defaultcborfeature. So no legitimate client of these three servers is rejected. - Scope:
RequireJsonwraps only theHttpServer, so it affects/rpc/*and not the guid-gated/ws/rpc/{guid}and/rest/rpc/{guid}continuations.local_hosts_onlysits inapply_outer_layers, so it covers the UI fallback and the continuations too.add_security_headersstill wraps the 403. - Host matching:
request_authorityprefers the URI authority, which covers HTTP/2:authority, and falls back to Host.is_local_hosthandles bracketed IPv6, a trailing dot, ports (which are stripped byAuthority::host), and the.local.attacker.exampleandnip.iorebinding shapes. The tests cover both sides. - Main server unaffected:
RpcContextkeepsCorsandredirect_service_domains, so the wizard's cross-origin final call to the new main server still works.
No changes requested.
Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
Helix-Identity: helix-b
|
@dr-bonez Cross-review approved the final head without requesting changes. Your original implementation and commit are unchanged; I added only an empty takeover commit, confirmed the source matches your submitted head, and reused your recorded verification. The description now includes the handoff brief and evidence provenance. The branch is mergeable; current-head CI is still pending, not yet green. Ready for your final judgment. GitHub cannot formally request a review from you because you are this PR’s author. |
helix-white
left a comment
There was a problem hiding this comment.
Approved following @helix-b’s independent cross-review of bf9aeb5. No implementation changes were requested or made during takeover; the original author’s verification evidence is retained in the PR brief. CI completion remains a separate merge gate.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
@dr-bonez the cross-review approved this with no changes, and the description is now the hand-off brief. GitHub can't request your review because you opened the PR, so this comment is the hand-off. CI is still running on |
The setup, init and diagnostic servers have no authentication. They used the shared CORS middleware, which reflects any Origin with credentials allowed and approves every preflight. rpc-toolkit also parses a request body as JSON whatever its Content-Type says. So any public web page opened by someone on the LAN could read
setup.disk.listandsetup.get-pubkey, and could callsetup.executeor the diagnostic actionsdisk.forget,restartandrebuildwhile the device was in one of those modes. Current Chrome and Firefox show a Local Network Access prompt first; Safari does not. This affects 0.4.0.4 and master.Summary
These changes apply to those three servers only:
/rpc. A newRequireJsonrpc-toolkit middleware returns 415 with an empty body unlessContent-Typeisapplication/json(parameters and case are ignored). Without it, atext/plainor form POST counts as a "simple" request that browsers send without a preflight, and it would still run the method.local_hosts_onlylayer serves a request only when its Host or:authorityis an IP literal,localhost, or a name ending in.local(a trailing dot is allowed). Any other host gets a 403 with the localized text "Open this server at its .local address or IP address." This stops DNS rebinding from making an attacker's page same-origin. The layer sits outside the whole router, so it also covers the UI files and the/ws/rpc/{guid}and/rest/rpc/{guid}continuations. The existing security headers still wrap the 403.The authenticated main, registry and tunnel servers keep their CORS behavior. Their credentials travel only in request headers, so a cross-site request carries none, and the setup wizard's final step calls the new main server cross-origin.
User-visible consequence: during setup or diagnostics, a server reached through a router-assigned name such as
start9.lannow shows the 403 text. A user has to usestart.local, the<hostname>.localname, or the IP, which is where the docs already send them. The changelog entry, in all five locales, says the same.Implementation diff: +87 / −4 lines in 4 files (excludes lockfiles, tests, docs, release notes, and changelog).
Approach
HttpServiceposts object bodies through Angular's HttpClient, which sendsapplication/json. The CLI'sCallRemoteimplementations forSetupContext,InitContextandDiagnosticContextgo throughsignature::call_remote_with_client, which sendsapplication/json. They do not use rpc-toolkit'scall_remote_http, which sendsapplication/cborunder the toolkit's defaultcborfeature. CBOR clients of these three servers are therefore rejected, and none exists.UiContext::apply_outer_layershook that the main server already uses for its domain redirect, and reads the host with the existingnet::http::request_authority. The content-type rule is an rpc-toolkitMiddlewarebecause it applies only to RPC calls..localname rather than only this device's hostname, because mDNS names can't be served by a rebinding attacker's public DNS. That keeps the check stateless, so it works before a hostname exists, during init, and in diagnostics.Neighbors
#4216 (private registry packages) edits the import block next to this PR's new imports in
net/static_server.rs. Whichever merges second may hit a small import conflict; the two changes don't overlap in behavior.Testing
bf9aeb5),cargo test -p start-core --features=test --libran the three new tests and all passed:simple_request_content_types_are_rejected_unprocessed: a missing Content-Type,text/plain, form-urlencoded and multipart each get 415 with an empty body, so the method never runs.json_requests_are_handled:application/jsonwith mixed case and a charset parameter reaches the handler.local_hosts_only_rejects_rebound_names:.localnames (including a trailing dot and a port), IPv4, bracketed IPv6 andlocalhostpass.attacker.example,start.local.attacker.example, a barelocaland192.168.1.5.nip.ioget 403.static_server,middleware,mcp,setup,diagnosticandnet::httpmodules, a passingcargo checkfor start-os, start-cli, start-registry and start-tunnel, and passing rustfmt, prettier and changelog-version checks.localhost, which the host guard allows.Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
Helix-Identity: helix-b