Repository navigation
fix(desktop): restrict local frontend access to electron - #835
Merged
Merged
Conversation
Authenticate all desktop frontend requests with a launch-only capability shared over private controller stdin. Scope credential injection to owned Electron windows and revoke it on shutdown or controller exit. Preserve the narrow OAuth callback and existing profile storage. Remove desktop browser-opening actions and disable desktop HTTPS over Tailscale while keeping paired Network access clients supported.
nixuuu
enabled auto-merge (squash)
November 15, 2026 14:09
nixuuu
added a commit
that referenced
this pull request
Nov 16, 2026
## Change Closing the last Windows window could throw `Object has been destroyed` after shutdown was latched, leaving services running and both Open and Quit in the tray inactive. Check BrowserWindow and WebContents liveness before session revocation, header authorization and IPC authorization; capture navigation targets before teardown. Local desktop sidebar preferences now use a stable scope instead of the gateway's random port, preserving grouping, project order and the Working section across restarts. Remote desktop and server scopes stay isolated. Existing port-derived records cannot be reliably migrated, so users may need to select their preferences once after upgrading. Fixes: #835 Fixes: #583 ## Verification - 39 focused tests passed: desktop session security, IPC delivery, app routes, quit guard and device-view persistence. Temp-directory checks passed. - Desktop typecheck, lint and formatting of edited files, and diff checks passed locally. - Real Electron on Linux reproduced the old destroyed-window getter failure. The patched lifecycle completed session revocation and quit when closing the last window, invoking Quit with live windows, and invoking Quit after closing the main window while settings remained open. - Updated desktop and UI/API documentation. No UI layout or copy changes; copy audit is not applicable. The full repository gate runs in CI. Native Windows verification remains outstanding; the Linux lifecycle smoke does not verify Windows integration or the full packaged runtime shutdown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Opening the desktop's loopback frontend in a browser or local HTTP client previously exposed the application. Require a random 256-bit capability for each launch, shared between Electron main and its controller through private stdin and checked before SvelteKit for documents, assets, API requests and SSE. Electron adds it only to owned windows and trusted top-level requests, strips it from external destinations, and revokes it before shutdown or immediately after controller exit.
Keep the exact GET OAuth callback available to the system browser, with existing state, binding and expiry checks. Preserve the frontend origin and profile storage. Hide desktop “Open in new tab” actions and prevent internal links from opening in the system browser. Disable HTTPS over Tailscale for desktop gateways to close the alternate browser entry; paired Network access clients and server gateways remain supported.
Update the architecture, desktop, remote frontend, Tailscale and UI/API docs, including the protection's limits against processes that can read memory or attach a debugger.
Verification
Passed locally on Linux:
CANOPY_CHANNEL=nightly bun run --cwd apps/desktop build; rebuilt the Electron shell after the final shutdown change.git diff --check.The full repository gate runs in CI. Native macOS/Windows startup and a complete OAuth sign-in through the system browser against a real provider remain unverified locally.
Copy audit (
docs/copy.md§8): pass. Desktop “Open in new tab” → hidden, because internal pages stay inside Canopy. Unauthorized content → “Open Canopy to use this app.” Desktop HTTPS availability → “Open this computer in Canopy. Browser access is unavailable.” Shutdown failures state that services stopped and ask the user to restart Canopy. New copy is English, uses plain language, and gives an action without exposing implementation terms; no audit exceptions.