Repository navigation
fix(desktop): refuse dashboard top-level navigation off the app origin - #23868
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The change is a main-process navigation guard in [UX-REVIEWED] 6ddb90b Description read[DESCRIPTION-READ] 078ee0c04308d548452d866f56106a22778dcb0306430e5ed66242ebbb0f197a That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The change reuses What this change shipsInventory (4 items) — 4 justifiedIntent: stop a page inside a dashboard pane from replacing the desktop app's main window and taking over its permissions. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 6ddb90b Description read[DESCRIPTION-READ] c4d2464b0f9860bff59135df9ce9f5ef664324cdba0d32a7d3f89f28fcc30e0a That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. Every in-app top navigation under Notes
[DESIGN-REVIEWED] 6ddb90b Description read[DESCRIPTION-READ] 1ff1521acde920724990f4204cf2082931b7600da007705435cac1fe705c1c7b That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
🤖 AI-assisted comment 🤖 |
A pane iframe can top-navigate the dashboard WebContents to its own document, which then inherits the dashboard's default-session grants. Add a deny-only will-navigate guard on the dashboard view and its pop-out windows: only http(s) URLs on the window's own origin pass; everything else is refused and nothing is opened externally.
e8ce81b to
6ddb90b
Compare
|
Review-ready on head 6ddb90b. All 107 checks pass, 0 failing; label 🤖 AI-assisted comment 🤖 |
cruisercohen
left a comment
There was a problem hiding this comment.
Reviewed 6ddb90b0f6 merged onto current main. Comment only: this is a desktop navigation guard, so it is security scope for us.
What it does. A new will-navigate guard (createNavigationGuard) runs on the dashboard view and on every pop-out. It allows a top-level navigation only when the scheme is http(s) and classifyNavigation says "allow". That check compares full WHATWG origins exactly (target.origin === new URL(appOrigin).origin) and rejects an opaque "null" origin, so a different port, userinfo, or a longer host or port can't pass. A refused URL is dropped (preventDefault plus a log line with the origin only) and is never handed to openExternal. The window-open hand-off is unchanged and still allows only cross-origin http(s) and the two System Settings URLs. The guard is always on.
Nothing legitimate breaks that I could find: same-origin location changes and pop-outs pass, and the OAuth path avoids blank tabs. The one behaviour change is that a plain external <a> without target=_blank now does nothing, where before it replaced the dashboard.
Checks run. window-lifecycle (48) and external-scheme (33) tests: 81 pass, run against a one-line electron stub because node_modules was absent. Removing the will-navigate hookup turns 2 tests red.
Non-blocking, hardening:
- Swapping the exact origin comparison for a prefix match leaves all 81 green.
createNavigationGuardhas no unit tests of its own, so a few prefix / userinfo / longer-port cases would pin the exact compare. will-redirectisn't guarded. A same-origin URL the server redirects off-origin would still navigate the window. I found no such redirect today: the browser-view relay refuses an off-originLocation, and the other redirects are path-only. Awill-redirecthookup using the same guard would close the class, possibly alongside thesandboxitem still open on #10657.
|
@cruisercohen thanks for the review (review). Exact-compare tests. Agreed. A prefix-match mutant passing all 81 tests means the exact origin compare is not pinned. Two ways to close it:
I will do (a) if you prefer it.
🤖 AI-assisted comment 🤖 |
buluoray
left a comment
There was a problem hiding this comment.
Approving 6ddb90b0f6a1ec11dd8c13d499f6b88f985811c8.
What it fixes. A page loaded into a dashboard pane could top-navigate the desktop app window and take over the dashboard's session grants. The dashboard view and every pop-out now refuse any page-started top-level navigation that is not http(s) on the window's own origin.
What I checked.
createNavigationGuard(external-scheme.js) allows only when the scheme is http(s) andclassifyNavigationreturnsallow; that check is an exact WHATWG origin equality with the opaque"null"origin rejected. Every other path, including a parse error, callspreventDefault(), and a throwing log sink cannot undo the refusal.- It is armed inside
armWindowOpen, so the main view and each recursive pop-out child get it, with the samewindowBackendUrlthe window-open handler and capture gate use. That value is alwayshttp://localhost:<port>; remote hosts come in through a local tunnel port. - Probed the guard directly: a different or longer port,
user@hostconfusion (localhost:5476@other.host), https on the same port, trailing-dot host,[::1],ws:,javascript:,data:,about:blankare all refused. Only true same-origin spellings (uppercase scheme/host, userinfo on the real host, leading-zero port) pass. - The token prompt hand-off goes to
http://localhost:<port>?…, which is the window's own origin, so it still works.
Tests. test/window-lifecycle.test.js + test/external-scheme.test.js: 81 pass. Mutants, one at a time: guard unwired, scheme check dropped, catch-allows, preventDefault removed and hostname-only compare are each caught by refuses a top-level navigation off the app origin…. One survives: changing the origin compare to startsWith reddens nothing, because no test uses a port-prefix target.
CI. On this head: 91 success, 13 skipped, 0 failure; all review lanes pass. Auto-merge is off.
Follow-ups (non-blocking).
- Add
http://localhost:54760/(port-prefix) to the new test so astartsWithregression is caught. - A same-window external
<a href>in the dashboard is now a dead click; consider handing refused http(s) targets to the browser in a later PR if any such link exists. - The packaged-app manual check (pane, credential prompt, 403 retry) is still worth doing once.
|
@cruisercohen the exact-origin tests you suggested are in the test-only follow-up PR #23938. 🤖 AI-assisted comment 🤖 |
Problem / Motivation
Goal: A page inside a dashboard pane can no longer take over the desktop app's main window.
The instances-pane iframe can top-navigate the dashboard window. The dashboard WebContents has no
will-navigateguard, so the pane's own document then becomes the top frame. That document holds every default-session grant the dashboard has, includingmedia(the microphone) for localhost origins. The capture trust gate from #9112 already refuses the screen-capture part; the navigation itself is still allowed.Why it matters
Any page served into a pane (a remote crew, a local app on another port) could promote itself to the main window and act with the dashboard's permissions. A promoted page also strands the user: the app is no longer showing the dashboard.
Not a goal
sandboxto the instances-pane iframe (the issue's other item). It can break the pane, so it needs its own PR and a manual check.What changed (motivation → approach → change)
A pane top-navigates the dashboard → no
will-navigatelistener on the dashboard WebContents → add one that refuses the move.http(s)on the window's own origin (scheme, host and port)127.0.0.1vslocalhostfile:,blob:,data:, unparseablecreateNavigationGuardinwebsite/electron/external-scheme.jsreuses the existingclassifyNavigationsame-origin check.window-lifecycle.jsarms it on the dashboard view and on every pop-out window, next to the window-open handler. A refusal logs only the target's origin, never the full URL. Main-processloadURL/loadFilecalls do not emitwill-navigate, so boot, reconnect, token retry and recovery loads are unaffected. The token prompt's own hand-off goes tohttp://localhost:<port>, which is the window's origin, so it still passes.Decision on "own origin": the origin each window was opened on (
windowBackendUrl), the same value the capture trust gate and the window-open handler already use. Exact match, no loopback-alias widening.Backwards compatibility
Compatible: every in-app top navigation in
website/srcgoes throughwithBase(...)on the dashboard origin, and every shell page hands off to the window's own origin.Reader: website/electron/window-lifecycle.js:setupWindowContents -- release -- dashboard routes and the token-prompt hand-off stay same-origin;
refuses a top-level navigation off the app originchecks both.Reader: website/src/hooks/useFrameSrc.ts:location.replace -- crew page -- navigates the pane iframe, not the top frame, so
will-navigateon the main frame does not see it.Tests
test/window-lifecycle.test.js›refuses a top-level navigation off the app origin, in the dashboard and its pop-outs: other port,127.0.0.1, foreign https,file:,blob:and junk are refused on the dashboard and a pop-out; own-origin routes and?token=pass; nothing is opened externally.view.on:will-navigateregistration.Proof: not provable -- frontend test (prove.py runs Python only)
Local GPT and Opus review lanes on
e8ce81bbae: no findings. The backend scoped set was not run locally (this worktree lacks the backend venv); CI runs it.Mutants, each run against the new test: guard not wired → fails; guard allows everything → fails; guard allows any web origin → fails. Clean head passes.
npm run test:electron: 2866 pass, 0 fail.Manual verification
Not run: this host cannot launch the packaged app. A maintainer check worth doing: open the dashboard, open a remote-crew pane, and confirm normal in-app navigation, the token prompt, and a 403 token retry still work.
Related Issues
Part of #10657
Sibling sweep
Swept: git grep -nE "new (BrowserWindow|WebContentsView)(|will-navigate" -- website/electron
Sibling: website/electron/mochi/panelWindow.js -- not affected -- already has a will-navigate guard on its base URL
Sibling: website/electron/mochi/snipWindow.js -- not affected -- loads one fixed gateway page and hosts no pane iframe
Sibling: website/electron/runtime/window/browser-panels.js -- not affected -- browser panels are meant to browse and use their own deny-all partition
Pattern harvest
Rule candidate: review-prompt
Pattern: a WebContents that embeds third-party iframes needs a will-navigate guard, or a frame can promote itself to the top frame.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)