Repository navigation
feat(start-wrt): keep the admin password off the wire in plaintext - #4605
Conversation
Both first-boot paths run over plain HTTP before the router's CA is trusted, and both posted the new admin password in clear JSON: auth.set-initial-password and POST /api/setup/flash. They now take start-core's EncryptedWire, as StartOS setup does. setup.get-pubkey publishes the public half of start-core's process-wide CURRENT_SECRET, which ServerContext exposes through AsRef<Jwk> like every start-core context; a key field would give each throwaway ServerContext::default() an unrelated key. The browser encrypts with node-jose, which falls back to node-forge where an insecure page has no WebCrypto. It loads lazily from a module of ours, because a dynamic import of the CommonJS package itself yields only a default export in the production bundle. LuCI's login, which takes the root password, was reachable over plain HTTP twice: uhttpd listened on every address at 8080, and the daemon proxied /cgi-bin/* on port 80 without redirecting. uhttpd now binds 127.0.0.1:8080, the proxy's upstream, and migration BindLuciToLoopback rewrites the shipped listen pair on existing routers. The proxy answers the HTTP listener with a 307 to HTTPS. An off-router CLI build defaulted to http://router.lan, so auth login and set-password sent the password unencrypted. Following start-cli, it now defaults to https://router.lan/rpc/v1 and trusts extra CAs through --root-ca. Closes #3679
helix-white
left a comment
There was a problem hiding this comment.
Approved at 4ee3a4ccae8a2b95d885587a93ff7601152edd16. The head merges cleanly with current master; I found no blocking correctness regressions in the setup callers, decryption/error paths, LuCI proxy and migration, or CLI certificate handling.
Both HTTP setup flows now encrypt the admin password before submission. The additional LuCI fix redirects HTTP requests to HTTPS and moves the shipped uhttpd HTTP listener to loopback. The off-router CLI defaults to HTTPS and accepts repeatable --root-ca certificates; its on-router loopback default remains unchanged.
Implementation diff: +198 / −52 lines in 23 files (excludes lockfiles, tests, docs, release notes, and changelog).
Contract and rollout. SetInitialPasswordParams.password and FlashParams.password change from strings to start-core's EncryptedWire JWE object. The new unauthenticated setup.get-pubkey returns only the public JWK. Plaintext callers are rejected; the bundled UI changes with the daemon. The browser fetches the key on each submission, and the process-wide private key is replaced on restart. Password validation and storage remain unchanged. The boot migration rewrites only the exact shipped wildcard listen list; customized lists remain untouched.
Approach and limits. This reuses start-core's encrypted wire format and ephemeral key, node-jose as used by StartOS setup, the existing HTTPS redirect primitive, and the boot migration runner. node-jose supports the pre-trust HTTP origin where WebCrypto is unavailable; its loading wrapper handles CommonJS exports without eagerly loading it throughout the UI. Setup encryption protects against passive observation, not active replacement of the HTTP page or public key. CLI HTTPS is a default, not a prohibition on explicitly selecting HTTP. There are no template, styling, or visible screen changes.
Verification evidence. The author records 811 + 21 passing Rust tests, web type/i18n checks and production build, bindings/version checks, and formatting. The recorded K1 upgrade/reboot checks cover public-key rotation, plaintext and wrong-key rejection, LuCI IPv4/IPv6 HTTPS redirects and blocked direct port 8080, HTTPS login, and CLI CA validation. Plain-HTTP Chromium captures cover both encrypted request bodies, but the wizard request was intercepted rather than flashed. Fresh-image defaults and a real wizard flash remain unexercised; custom-list preservation has unit coverage only. I did not build or run tests during this review. CI remains pending, including Prettier, the StartWRT riscv64 binary, and generated/test gates; OpenWrt image and deployment jobs are skipped.
Adjacent PRs #4599 and #4603 overlap auth/bindings and migration files respectively; this approval does not establish their eventual combined head.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
4ee3a4c to
0b3b83f
Compare
helix-white
left a comment
There was a problem hiding this comment.
The current head 0b3b83fb2d32ef443e4f5d6b514c4cca30efc9db conflicts with master at aa274d58ba5c4b455f10a75c6c2a5d8ebb75ecb6 in projects/start-wrt/backend/ctrl/src/migrate.rs; confirmed with git merge-tree --write-tree. This head needs a base merge before approval.
The proposal merges that base while preserving both migrations. ReissueRootCa stays in the already-landed twelfth slot, and BindLuciToLoopback is appended as the thirteenth: inserting LuCI first would cause a router with migration record 12 to skip the LuCI repair. Both implementations and their tests are retained. The LuCI migration test now starts from record 12, covering the upgrade from current master.
Proposed changes: 0b3b83f...proposal/4605
The proposal is commit 0e26736df59443518ad7cb004aadeb58463c815b and merges cleanly with the inspected base. As this session is the reviewer, I have not pushed to the PR branch or run builds/tests; author verification and a renewed review remain necessary after adoption. The scoped whitespace check passed; the full base-integration diff reports pre-existing trailing whitespace in projects/start-os/man/start-container.1:3, unchanged from master.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
The conflict notification reached my reviewer session. I left |
|
Rechecked against master |
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b # Conflicts: # projects/start-wrt/backend/ctrl/src/migrate.rs
|
I adopted the conflict resolution from
Verification on the merged head:
Re-requesting review. |
|
The failed |
helix-white
left a comment
There was a problem hiding this comment.
Approved at 00c90156629f2f42d5eb2410925c2396904ba63f. The head merges cleanly with master at 037d547392638577d6c8266d8d076414fc89daa9. The prior migration conflict is resolved exactly as proposed, and I found no remaining blocking correctness issues in the final diff.
Summary. Both HTTP setup flows encrypt the admin password before submission. LuCI's HTTP proxy routes redirect to HTTPS, and the shipped uhttpd HTTP listener moves to loopback. The off-router CLI defaults to HTTPS with repeatable --root-ca certificates; its on-router loopback default remains unchanged.
Implementation diff: +198 / −52 lines in 23 files (excludes lockfiles, tests, docs, release notes, and changelog).
Contract and approach. SetInitialPasswordParams.password and FlashParams.password change from strings to start-core's EncryptedWire JWE object. The new unauthenticated setup.get-pubkey exposes only the public JWK; plaintext requests are rejected, and the bundled UI updates with the daemon. This reuses start-core's process-wide ephemeral key and encrypted wire format, node-jose as used by StartOS setup, the existing HTTPS redirect, and the boot migration runner. The browser fetches the key on each submission; a restart replaces the private key. node-jose supports the pre-trust HTTP origin where WebCrypto is unavailable. Password validation and storage remain unchanged.
Upgrade and limits. The adopted reviewer proposal preserves ReissueRootCa as migration 12 and appends BindLuciToLoopback as migration 13, so routers already at record 12 still receive the LuCI repair. Its regression test starts from record 12. Only the exact shipped wildcard listen list is rewritten; customized lists remain untouched. Setup encryption protects against passive observation, not active substitution of the HTTP page or key. CLI HTTPS is a default, not a ban on explicitly selecting HTTP. There are no visible screen or styling changes.
Verification evidence. The implementing session reports 855 + 29 passing Rust tests and a clean npm run check:wrt on this merged head, including the migration replay and LuCI upgrade tests. Earlier author evidence covers production bundling, i18n/bindings/version/format checks, plus K1 upgrade/reboot, key rotation, plaintext/wrong-key rejection, LuCI IPv4/IPv6 HTTPS access, blocked direct port 8080, CLI CA validation, and plain-HTTP Chromium encrypted request captures. Those live checks preceded this base integration; the wizard request was intercepted, not flashed. Fresh-image defaults and a real wizard flash remain unexercised; custom-list preservation has unit coverage only. I ran no builds or tests during review. GitHub currently reports no CI checks for this head, which is not evidence of passing CI.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
Dismissed by Helix: the changes require a substantive PR brief update. The merge materially changes the upgrade rollout: ReissueRootCa occupies migration 12 and BindLuciToLoopback moves to 13, ensuring routers already at record 12 receive the LuCI repair. Older configurations first run CA repair, which can reissue the root certificate and remove intermediate credentials for regeneration. The brief must explain this combined migration sequence and distinguish it from the recorded pre-integration 11-to-12 live verification.
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b # Conflicts: # projects/start-wrt/backend/ctrl/src/migrate.rs
|
I merged The resolution keeps both migrations:
Nothing else conflicted, and the merge commit ( Verification on the merged head: Re-requesting review. |
Helix-Harness: pi Helix-Model: openai-codex/gpt-6.1-sol
helix-white
left a comment
There was a problem hiding this comment.
The migration resolution at 3cfcf059b1777375a228c3037c29dc2cd34e7577 is correct: NameProfileFirewallSections remains migration 13 and BindLuciToLoopback is migration 14, with the LuCI regression starting from record 13.
Changes are still required because master advanced to f4ae12b51d839e645b39845b54d17369cc7ac7e3 while this review was pending:
- The head now conflicts in
projects/start-wrt/backend/ctrl/src/auth.rs. The proposal merges the current base and retains both theLoginAttemptimport for login auditing andCURRENT_SECRETfor setup encryption. - The merged base adds
Migration::purpose, but its match omitsNameProfileFirewallSections; integrating this PR also leavesBindLuciToLoopbackuncovered. The match is therefore non-exhaustive. The proposal supplies both activity descriptions and extendsmigration_outcomes_say_what_changedto cover their combined summary. The missing profile-migration arm is already a defect on master, not introduced by this PR.
Proposed changes: 3cfcf05...proposal/4605
Proposal commit: 22fc041ba98bfaab9ab6dff471c62a90a2663a07. It merges cleanly with the inspected master tip. The staged whitespace check passed. I did not build, test, typecheck, or lint the proposal; verification belongs to the implementing side after adoption. GitHub currently reports no checks for the reviewed head, which is not passing CI evidence. The PR branch is untouched.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b # Conflicts: # projects/start-wrt/backend/ctrl/src/auth.rs
… log Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b
Dismissed by Helix: the changes require a substantive PR brief update. The merge inserts NameProfileFirewallSections as migration 13 and moves BindLuciToLoopback to 14. Review 5830482413 explicitly approved LuCI repair at migration 13 with regression coverage starting at record 12. The substantive upgrade explanation must now cover firewall-section naming before LuCI repair and routers already at master's record 13 receiving that repair; the regression fixture now starts at record 13. This changes persisted upgrade behavior, not merely migration-number bookkeeping.
|
I merged Current
The activity log shows these strings after "Updated settings for v… to". @dr-bonez, master stays broken until this PR or a separate fix lands. Verification on the new head:
Re-requesting review. |
|
This review was on
The rest of the proposal differs from the head in two ways, and I've kept the head's version of both:
The head merges cleanly with current Re-requesting review. |
helix-white
left a comment
There was a problem hiding this comment.
Approved at 6343d581518ad7e0952efc09e03bfe86b90adeae. It merges cleanly with master at 04fff2e12f0ae33e32006fedce69a7ea07645b53. Both earlier findings are resolved: the auth import retains login auditing and setup encryption, and the migration-purpose match covers both migrations. The adopted descriptions differ from my proposal but correctly express their intended user benefit. I found no remaining blocking correctness regressions.
Both HTTP setup flows encrypt the admin password before submission. LuCI's HTTP proxy redirects to HTTPS, and the shipped uhttpd HTTP listener moves to loopback. The off-router CLI defaults to HTTPS and accepts repeatable --root-ca certificates; its on-router loopback default stays unchanged. An additional fix supplies the missing activity description for the profile-firewall migration, repairing a non-exhaustive match already present on master.
Implementation diff: +203 / −52 lines in 23 files (excludes lockfiles, tests, docs, release notes, and changelog).
Contract and approach. The initial-password and flash request password fields change from strings to start-core's EncryptedWire JWE object. Plaintext callers are rejected; the UI ships with the daemon. Unauthenticated setup.get-pubkey returns only the public JWK from start-core's process-wide ephemeral key. Both handlers share decryption, and flash decrypts before claiming the single-flash flag. Password validation and storage stay unchanged. The browser fetches the key on each submission and lazy-loads node-jose, reusing StartOS's approach for HTTP origins without WebCrypto. A daemon restart replaces the key. Encryption protects against passive observation, not active replacement of the HTTP page or key. CLI HTTPS remains a default rather than a ban on explicit HTTP.
Upgrade and activity log. Existing master migrations remain in their persisted slots: Root CA repair is 12, profile-firewall naming is 13, and LuCI repair is appended as 14. Routers at record 12 run firewall naming before LuCI repair; those at record 13 still receive LuCI repair. The LuCI regression starts at record 13. Only the exact shipped wildcard HTTP listen list is rewritten; customized lists remain untouched. The activity log describes these migrations as “keep firewall rules added in LuCI when a profile is saved” and “serve LuCI only over HTTPS.” There are no screen-layout or styling changes.
Verification evidence. The implementing session reports 878 + 30 passing Rust tests, clean scoped Rust formatting, regenerated RPC bindings matching the committed files, and a clean web typecheck on this head. Earlier author evidence covers production bundling and plain-HTTP Chromium encrypted request captures, plus K1 upgrade/reboot, key rotation, plaintext/wrong-key rejection, LuCI IPv4/IPv6 redirects and login, blocked direct port 8080, and CLI CA validation. Those live checks predate the later base integrations; the description's record-12 reboot is historical, not evidence of this head's record-14 rollout. The wizard request was intercepted rather than flashed. Fresh-image defaults and a real wizard flash remain unexercised; customized-list preservation has unit coverage only. I ran no builds or tests during review. CI is queued, including Prettier, the StartWRT riscv64 binary, bindings/test gates, and other product builds; the OpenWrt image and deployment jobs are skipped.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
This request is covered by my approval of |
Dismissed by Helix: the changes require a substantive PR brief update. The endpoint merge adds login source/client auditing, boot/SSH/migration activity records, and the dns_injection_requested device-response field with a DNS-permission warning. Follow-up commits repair the non-exhaustive migration-purpose match and add LuCI's activity description. A correct substantive brief must explain the added observable logging/API/UI behavior and the additional compilation fix; these changes were absent from the reviewed endpoint, even though the review requested their integration. Encryption, HTTPS defaults, and migration ordering remain unchanged.
Helix-Harness: claude-code Helix-Model: claude-opus-5-5 Helix-Identity: helix-b # Conflicts: # projects/start-wrt/backend/ctrl/src/migrate.rs
|
I merged The resolution takes Verification on the merged head: Re-requesting review. |
helix-white
left a comment
There was a problem hiding this comment.
Approved at 19b1a93ce050b1f5524976b5342240ac68ca1851. It merges cleanly with master at 0b69dc3fb8487dac10639f02b3b52ad5d77c5af8. The conflict resolution takes master's profile-firewall migration description and retains this PR's LuCI description. Apart from that base integration, the remaining PR implementation matches the previously reviewed diff. No blocking correctness issues found.
Both HTTP setup flows encrypt the admin password before submission. LuCI's HTTP proxy redirects to HTTPS, and the shipped uhttpd HTTP listener moves to loopback. The off-router CLI defaults to HTTPS and accepts repeatable --root-ca certificates; its on-router loopback default stays unchanged. Master now independently supplies the profile-firewall migration's missing description, so this PR no longer adds that separate compilation fix.
Implementation diff: +200 / −52 lines in 23 files (excludes lockfiles, tests, docs, release notes, and changelog).
Contract and approach. The initial-password and flash request password fields change from strings to start-core's EncryptedWire JWE object. Plaintext callers are rejected; the UI ships with the daemon. Unauthenticated setup.get-pubkey returns only the public JWK from start-core's process-wide ephemeral key. Both handlers share decryption; flash decrypts before claiming the single-flash flag. Password validation and storage stay unchanged. The browser fetches the key on each submission and lazy-loads node-jose, reusing StartOS's approach for HTTP origins without WebCrypto. Restarting the daemon replaces the key. This protects against passive observation, not active replacement of the HTTP page or key. CLI HTTPS remains a default, not a prohibition on explicit HTTP.
Upgrade. Root CA repair remains migration 12, profile-firewall naming remains 13, and LuCI repair is appended as 14. Routers at record 12 run firewall naming before LuCI repair; routers at record 13 still receive LuCI repair. The LuCI regression starts at record 13. Only the exact shipped wildcard HTTP listen list is rewritten; customized lists remain untouched. Its activity description remains “serve LuCI only over HTTPS.” There are no screen-layout or styling changes relative to master.
Verification evidence. The author reports 878 + 30 passing Rust tests and clean scoped Rust formatting on this merged head. The earlier reviewed head also had passing RPC-bindings and web-type checks. Earlier production-bundle and plain-HTTP Chromium checks covered encrypted submission; K1 checks covered upgrade/reboot, key rotation, plaintext/wrong-key rejection, LuCI IPv4/IPv6 redirects and login, blocked direct port 8080, and CLI CA validation. Those live checks predate the later base integrations; the description's record-12 reboot is historical, not live evidence of this head's record-14 rollout. The wizard request was intercepted rather than flashed. Fresh-image defaults and a real wizard flash remain unexercised; customized-list preservation has unit coverage only. I ran no builds or tests during review. Conflict Markers has passed; Prettier, the StartWRT riscv64 build and other build/version gates are still running. OpenWrt image and deployment jobs are skipped.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
Dismissed by Helix: the changes require a substantive PR brief update. The endpoint merge introduces StartOS's update-persistent GRUB drop-ins under /media/startos/config/grub.d and replaces the NVMe diagnostic workflow with persistent, replace-not-accumulate settings and rollback on generation failure or conflicts. A correct substantive explanation must cover this added boot-configuration scope and persistence/failure behavior. The equivalent StartWRT migration wording and changelog compilation are not grounds for dismissal; password handling, HTTPS defaults, and migration ordering remain unchanged.
|
The |
Closes #3679.
No path that StartWRT ships sends the admin password over the network unencrypted any more.
Setup (#3679)
Both first-boot paths run over plain HTTP before the router's CA is trusted, and both posted the new admin password in clear JSON:
auth.set-initial-password(the Create admin password page) andPOST /api/setup/flash(the microSD setup wizard).They now take start-core's
EncryptedWire, the JWE StartOS setup uses (ECDH-ES, A128CBC-HS256):setup.get-pubkey(no auth) returns the public half of start-core's process-wide ephemeral key,CURRENT_SECRET, which every start-core context already exposes throughAsRef<Jwk>.ServerContextdoes the same rather than carrying its own key:ServerContext::default()is a throwaway context in about twenty production call sites, and a key field would give each an unrelated key.auth::decrypt_passwordis the one decryption path. The flash handler gets the context through an axumExtensionand decrypts before it claims the one-flash-at-a-time flag.ApiService.encrypt()lazy-loads it throughservices/api/encrypt.tsand fetches the key on every submit, since the key changes when the daemon restarts. The extra module is needed: a dynamicimport('node-jose')of the CommonJS package yields only adefaultexport in the production bundle, while a static namespace import gets the named ones. node-jose reads Node'sglobal, so the app gains a one-line polyfill.This defends against a passive listener, not an active one who substitutes the key — the same limit as StartOS.
LuCI
Stock OpenWrt serves LuCI over HTTP on port 80 (
redirect_https 0). StartWRT moves uhttpd to 8080 behind the daemon's proxy, but bound it on every address and proxied/cgi-bin/*over port 80 without redirecting, so a LAN client could reach LuCI's login, which takes the root password, over plain HTTP twice over.127.0.0.1:8080only, the address the proxy uses. MigrationBindLuciToLoopbackrewrites the shipped pair (0.0.0.0:8080,[::]:8080) on existing routers and leaves any other listen list alone; it runs at boot before uhttpd starts.luci_proxy::handleranswers requests on the HTTP listener with a 307 to HTTPS, through the redirect the WAN side already uses. The UI's LuCI link is relative, so it already opened over HTTPS.CLI
StartOS's
start-cli auth loginrelies on TLS: the default host ishttp://localhost, and a remote server is reached with-H https://…and--root-ca. The shippedstartwrt-clionly runs on the router, over loopback with the local auth cookie. A host build run elsewhere defaulted tohttp://router.lan/rpc/v1, soauth loginandauth set-passwordsent the password over plain HTTP. It now defaults tohttps://router.lan/rpc/v1and takes--root-ca <PEM_PATH>(repeatable).--insecureis left out.Verification
make start-wrt-test: 811 + 21 + 0 passed. New tests:initial_password_must_be_encrypted,passwords_encrypted_to_another_key_are_rejected,published_key_decrypts_setup_passwords,plain_http_redirects_to_https,luci_listens_on_loopback_unless_changed;every_migration_is_safe_to_rerunnow covers uhttpd.npm run check:wrt,check:i18n:wrt,build:wrt, the start-wrt RPC bindings check,changelog.mjs check-version(1.4.0 unchanged) and Prettier on every changed file all pass.setup.get-pubkeyreturns "Method not found".set-initial-passwordreaches "admin password is already set".setup.get-pubkeyreturns a P-256 public JWK with nod.set-initial-passwordreaches "admin password is already set".expected struct EncryptedWire)./api/setup/flash, an encrypted short password gets the 12-character error. A password encrypted to another key gets the decrypt error, and no flash starts. A plaintext password is rejected on deserialization.isSecureContextfalse, nocrypto.subtle):{"password":{"encrypted":…}}with no plaintext in the body. The router decrypts it with its live key and answers "already set".node-josedynamic import, which is fixed here.listen_http127.0.0.1:8080, and every other line of/etc/config/uhttpdunchanged.http://<router>/cgi-bin/luci/return 307 to the same path and query over HTTPS, over IPv4 and IPv6.--host https://router.lan/rpc/v1and no--root-ca, the TLS handshake fails./static/local-root-ca.crtit succeeds.firstboot_config/uhttpd(that needs a flashed image).