fix(desktop): add sidecar credentials from the main process - #47588
Merged
Conversation
… password in main
Hona
force-pushed
the
sidecar-auth-injection
branch
from
September 6, 2026 06:57
90f5762 to
61329e0
Compare
Hona
enabled auto-merge (squash)
September 6, 2026 07:00
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.
Follow-up to #47560. That PR made Desktop's CORS preflights cacheable; this one removes them from GET requests to the local sidecar entirely, and moves the sidecar credential out of the renderer.
The renderer at
oc://rendereris cross-origin tohttp://127.0.0.1:<port>, and the only thing that made its GETs non-simple was theAuthorizationheader. Per the Fetch spec a request with just CORS-safelisted headers needs no preflight, so if the renderer stops sending credentials and the main process adds them, every GET becomes one round trip instead of two. POSTs with a JSON body still preflight, but those are cached after #47560.Electron registers
webRequestlisteners in Chromium'sextraHeadersmode, which runs after the CORS decision; header changes made there do not trigger a preflight (the documented behaviour extensions rely on to add credentials).Changes —
packages/desktopCredential stays in main.
ServerReadyDataover IPC is now{ url }only; the password never reaches the renderer.SidecarCredentials(main/service/sidecar-credentials.ts) holds{ url, password }, is published on the initial connection and every reconnect, andready()is what the IPC handlers return.Injection is scoped to the renderer's own top-level frame. Anything else in the session (web views, embedded pages, sub-frames, frame-less requests such as a service worker) can reach the same loopback origin and gets nothing — the same rule
allowRendererPermissionsalready applies to permission requests. Fails closed whendetails.frameis null.authorization(sidecar, url)matches the request origin exactly against the sidecar origin; remote servers (WSL, Tailscale, manual) keep sending credentials from the renderer as before.sidecarHttppasses only the URL into the app'sServerConnection,createSidecarResolvercompares URLs, and the migration-status client no longer builds a header. The app package is untouched: a connection without a password already means "send no Authorization".Against the Electron security checklist
Authorizationitself, and the listener re-checks the origin on every leg.session.webRequest.setHeaderRules()(declarative, no main-process hop) lands in a newer Electron than 42; worth switching to when Electron is bumped.The web app / PWA is unaffected by this PR; it never had the desktop preflight-cache bug and keeps building its own header.