Repository navigation
fix(desktop): open WSL links via rundll32 instead of cmd start - #88558
JiuYue0820 wants to merge 1 commit into
Conversation
andrexibiza
left a comment
There was a problem hiding this comment.
Requesting changes. Removing cmd.exe /c start is the correct boundary fix, and rundll32.exe url.dll,FileProtocolHandler is a plausible WSL host launcher. The patch is not merge-ready yet:
1. The regression does not exercise the production WSL launch path.
The tests only assert that wslWindowsOpenUrlArgs() returns two constants. They never run or intercept the branch in openExternalUrl() that actually calls spawn(). main.ts could regress to cmd.exe /c start while these tests continued to pass unchanged.
isCmdStartUnsafeForUrl() is also dead production code used solely by its test; it does not protect the boundary.
Please extract the actual WSL launch operation behind injected spawn, fallback, and logging dependencies. The regression should call that production seam and assert that:
- the executable is not a command shell;
- the normalized URL is supplied as exactly one argv element;
- an
https:URL containing&,|,^,<,>, and%remains unchanged; - the same guarantee holds for an allowed
mailto:URL; - the old
cmd.exe /c startroute cannot be selected.
Then remove isCmdStartUnsafeForUrl().
2. The fallback currently handles spawn failure, not launcher failure.
ChildProcess#error fires when the process cannot be spawned. If rundll32.exe starts but exits nonzero because dispatch fails, the child emits exit/close; this function has already returned true, and shell.openExternal() is never called.
Add a once-guarded fallback covering both 'error' and nonzero termination. Test:
- spawn error → fallback once;
- nonzero exit → fallback once;
- error followed by exit → still fallback once;
- successful exit → no fallback.
3. There is no executed verification yet.
The PR says Vitest was not run and there was no live WSL click-through. The workflow is currently action_required with no test jobs executed. Since this changes a host-command security boundary, source-level inspection is not enough.
Please rebase onto current main, resolve the existing conflict, run the Electron Vitest project and typecheck, and provide one real WSL proof using a metacharacter-bearing URL.
The launcher choice itself is not my blocker. Removing cmd reparsing closes the reported injection class. The blockers are proof through the real execution path, complete failure handling, and the current unmergeable repository state.
cmd.exe /c start concatenates an unquoted URL on the Windows host. An ampersand in the query string then runs as a separate command. Use rundll32 url.dll,FileProtocolHandler so the URL stays one argument. Co-authored-by: FirmamentalSpring <287222957+FirmaSpring@users.noreply.github.com>
340ca81 to
a87d06d
Compare
|
Addressed the review on #88558.
The regression asserts:
Local results on this Windows 11 host:
WSL proof ( Exit 0. No new Happy to add a live Desktop click-through if you want that on top of the host-launcher proof. |
Re-review receipt — requested WSL boundary fixes are present at
|
What does this PR do?
On WSL,
openExternalUrlopened http(s)/mailto links withcmd.exe /c start "" <url>. WSL binfmt interop only quotes argv elements that contain spaces. A URL never does, so the URL is concatenated unquoted into the cmd command line.&in a query string is then a command separator: a chat/Markdown link such ashttps://example.com/?a=1&calc&z=2opens the first segment and runscalcon the Windows host.The WSL branch now launches
rundll32.exe url.dll,FileProtocolHandler <url>, which takes the URL as a single argument and does not re-parse it as a cmd line. Failure still falls back toshell.openExternal.The argv helper lives in
electron/wsl-open-url.tsso it can be unit-tested without booting Electron.Related Issue
No existing issue or PR covers this
cmd.exe /c startURL path. Filed as a PR directly.Fixes #
Type of Change
Changes Made
apps/desktop/electron/wsl-open-url.ts:wslWindowsOpenUrlArgs()returns rundll32 FileProtocolHandlerapps/desktop/electron/main.ts: WSLopenExternalUrluses that helperapps/desktop/electron/wsl-open-url.test.ts: asserts the helper never returnscmd.exe/startHow to Test
apps/desktop:npx vitest run --project electron electron/wsl-open-url.test.ts(this worktree has nonode_modules; the helper was checked by reading the source contract instead)https://example.com/?a=1&calc&z=2— Windows must not launchcalc; the URL should open in the host browser as a single addresshttps://example.com/pathlink still opensChecklist
Code
fix(scope):,feat(scope):, etc.)node_modulesnot present in the worktree). Source contract checked:main.tsno longer containscmd.exe /c startfor this path.Documentation & Housekeeping
For New Skills
N/A
Screenshots / Logs
N/A
AI assistance disclosure: found during a code review of
apps/desktop/electron/main.ts; the fix, tests, and this description were prepared with AI assistance (Grok 4.6 via PokeAPI) and reviewed by the human submitter (FirmaSpring). Live WSL click-through was not re-run in this environment; the argv change matches the rundll32 FileProtocolHandler approach described in the review notes.