Repository navigation
fix(windows): start the WSL holder with only a NUL handle to inherit - #35799
Conversation
fb8dc29 to
340437e
Compare
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
No actionable comments were generated in the recent review.
|
[Medium impact] The PR appears safe to merge; no actionable new issue was established. SummaryStarts the Windows WSL holder with an explicit inheritance list containing only a
|
libuv starts every Windows child with bInheritHandles=TRUE and no handle list, so a detached holder that outlives Orca kept any inheritable handle Orca had open, such as a launcher's pipe or a DevTools socket. Start it through CreateProcessW with PROC_THREAD_ATTRIBUTE_HANDLE_LIST naming one NUL handle for its stdio. The build probes now check the newest export without calling it, and the lane receipt labels ConPTY's own startup output.
340437e to
bd30fce
Compare
ELI5
When Orca starts a helper program on Windows, Windows copies into it every connection Orca has marked "shareable". The program that keeps a WSL distro awake (the "holder") runs long after Orca does. Anything it receives stays open for that long: a pipe a script is reading Orca's output from, a debugging socket, and so on. This change starts the holder with an explicit list of what it may inherit, and that list holds one "nowhere" handle (NUL) for its input and output. Nothing of Orca's comes along.
What Changed
Mechanism:
native/windows-securityaddsspawnDetachedIsolated:CreateProcessWwith extended startup info whosePROC_THREAD_ATTRIBUTE_HANDLE_LISTcontains only that handle.@orca/process-host/isolated-detached-spawnaddsspawnDetachedWithoutInheritance:pid,spawn,error,exit,close,killandunrefsurface the holder already used, with libuv's exit and kill reporting.cmd.exeor a relative path lookup.src/main/wsl/wsl-distro-holder.tsnow spawns through it.currentUserSid()andhasNativeExport('spawnDetachedIsolated'), which reads the binary the package actually resolved. So a binary built from older source still fails the probe and gets rebuilt. The native cache key now covers the new source files.conptyStartupOutputMs(ConPTY's own startup output, not the distro's), and a test comment now says nine distro restarts, not six.Why
CreateProcessWwith a handle list.Linked Issue
N/A (maintainer change; follow-up to #35678 in the WSL host idle-release work).
Visual Proof
N/A. There is no UI change: this only affects which handles Windows copies into the WSL holder process.
Testing
process-host unit tests (
isolated-detached-spawn.test.ts):.cmdor relative programs;spawn/exit/errorevents behave as expected;kill()the exit is reported as(null, 'SIGTERM'), and any other exit reports its code, so the holder's "exit code 1 means the distro stopped" rule keeps working;Startup unit test (
windows-isolated-spawner.test.ts): installs the spawner only when the binary exports it; no-op off Windows; never throws.Windows lane (
windows-isolated-spawner.win32.test.ts, registered inpr-package-test-paths.mjs):(null, 'SIGTERM')and an outside kill reports(1, null);errorevent namingCreateProcessW;Local (macOS):
pnpm run typecheck:ci, the touched tests,check:code-quality:changed, the ast-grep gates and the process-host import check pass. The native code compiles and runs only in Windows CI.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Reviewers: fix-reviewer, e9-reviewer (touches process spawning).
EDR notes:
PROC_THREAD_ATTRIBUTE_HANDLE_LISTis the standard way to limit inheritance; Chromium starts its own child processes this way.PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, which is parent-PID spoofing and is scored by EDR.cmd.exe /cor runtime code generation.wsl.exepath it was before, and the command line is byte-identical to what Node produced.Agent skill upstream boundary
Notes
Flag-off / User-risk: This is not behind a flag. It changes how the WSL holder starts, and the holder exists only when the WSL host feature is in use. If the addon is missing, stale or fails to load, Orca logs it and starts the holder exactly as before.
Remaining risk: a native spawn bug on some Windows version would make holder start fail. That surfaces through the holder's existing
errorhandling, which already treats a failed spawn as no holder.Exit watch: if Windows refuses the exit wait, the holder still runs and Orca logs that its exit is unobservable. The holder's existing liveness check, by pid, creation time and command line, still applies.
Security: narrows what the holder inherits; grants nothing new.
macOS/Linux: no-op.
SSH and remote: unaffected (local process start only).
Mobile: unaffected.
Performance: one native call per holder start.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)