You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(wsl): internal distro allowlist that keeps WSL execs out of other distros on shared test boxes - #34539
Automated test runs on a shared Windows test machine must not touch the owner's personal WSL distros. This adds an internal switch, the environment variable ORCA_INTERNAL_WSL_DISTRO_ALLOWLIST. When it is set, Orca refuses to run anything inside a distro that is not on the list.
User risk: none when the variable is unset. Users never set it. When it is unset, the check reads the variable and returns before looking at anything else, so every spawn behaves exactly as it does today.
What Changed
ORCA_INTERNAL_WSL_DISTRO_ALLOWLIST is a comma-separated list of distro names, matched case-insensitively, for example orca-d3-sd,orca-d3-plain. One pure check, assertWslDistroAllowed in @orca/process-host/wsl-distro-allowlist, runs before every wsl.exe exec Orca's own code makes:
process-host resolveSpawn. Every runProcess, runProcessSync and spawnProcess call passes through it, including the daemon's and the CLI's. That covers startup probes, distro discovery, home probes, the WSL host transport, the hook relay, preflight, early wake, retries and fallbacks. The WSL file watcher now spawns through process-host too (wsl-watcher-spawn.ts), so it is covered here.
resolveCommand (src/main/git/command-runner/wsl-command-resolution.ts). This is the single point where every Git, gh and glab path gets its wsl.exe -d <distro> … form. The check runs there, before the distro is noted as launched. So every spawn API that later runs the result is covered: execFileCapture (main and worker thread), gitExecFileSync, gitSpawn, the git stream reads, wslAwareSpawn, spawnCommandCapture and the process-host paths. Windows-host resolutions are never checked. With the variable unset, resolveCommand neither throws nor changes its output.
The terminal spawn sites:
main's degraded local PTY path (local-pty-runtime-spawn.ts);
the daemon's spawnNativeDaemonPty. This is checked before the macOS TCC and terminal-scope wrappers, so the real wsl.exe argv is what gets checked.
The remaining direct child_process wsl.exe calls, each checked inline before its exec:
codex-accounts managed-home execFileSync and the login spawn;
the WSL git-read environment probe, where a refusal resolves rejected;
the Codex hook path canonicalization, which settles unavailable asynchronously;
the CLI's WSL Claude sign-in spawn (src/cli/handlers/account.ts).
Guard against new bypasses.check:process-host-imports now fails on any non-test file under src/, outside process-host, that imports child_process, builds a wsl.exe exec ('wsl.exe', resolveWslExecutablePath() or buildWslExecArgs()), and neither calls assertWslDistroAllowed nor takes its program from resolveCommand, resolveGitCommand or resolveDefaultWslCli (checked centrally). config/scripts is exempt. It reports nothing on the current tree.
Rules while the variable is set (program basename wsl or wsl.exe, any case):
Exempt: pure list/status/version calls (-l/--list, -v, -q, --running, --all, -o/--online, --status, --version, --help), so discovery can still list distros and filter them.
Must name an allowlisted distro:-d/--distribution, -t/--terminate and --unregister. --distribution-id takes an id, not a name, so it is always refused.
Refused:--shutdown, and any call that names no distro before its command starts, since that would run in the default distro.
The scan stops at --exec, -e, --, or the first positional argument. wsl.exe treats its first non-option argument as a command for the default distro, so wsl ls -d Allowed is refused. Anything after that point is the guest command and is not inspected.
Malformed value (empty, an empty entry, or characters outside [A-Za-z0-9._-]): every distro is refused, list calls still work, and Orca logs once.
A refusal throws an error with code ORCA_WSL_DISTRO_NOT_ALLOWLISTED before any child process starts.
runProcess rejects, so async callers fall into their existing failure, retry and fallback handling. For example, the home probe resolves null, and the error is not classified as a transient WSL failure, so nothing retries in a loop.
spawnProcess and runProcessSync throw synchronously.
On Windows, a refused WSL terminal moves on to the next shell in its existing fallback chain.
orcad-windows-prebuild-cache.mjs now lists the new file among its cache inputs, since spawn-resolution.ts imports it.
Why
There is no single process boundary, so the same pure function runs at each place Orca starts a process in a distro, rather than several parallel implementations. process-host and resolveCommand together cover nearly every Windows spawn. The few remaining direct child_process calls are checked inline, and the import check keeps a new one from slipping in unchecked.
Unset costs nothing new:assertWslDistroAllowed reads the variable and returns before any argv work, at every call site. The string-argv split for node-pty's Windows command line happens inside the check, after that return.
Out of scope, on purpose. An exec allowlist only governs Orca's own wsl.exe invocations. It can't stop:
bash.exe (System32), wslg.exe, wslconfig.exe, and per-distro launchers such as ubuntu.exe;
wsl started through cmd.exe or powershell.exe;
wsl typed by a user in an Orca terminal.
external-editor launches with --remote wsl+<distro> (VS Code, Cursor and the like): the editor starts the distro itself, outside Orca's exec path.
Any \\wsl.localhost\<distro>\… or \\wsl$\<distro>\… read or write from Windows can boot or modify a distro without running wsl.exe. That includes file reads and writes, Windows Git on a UNC repo (including git maintenance and the direct-Git fallback), the restore-cwd probe, search and WSL account lanes. Verify runs on shared boxes must therefore use a clean profile with no saved UNC projects and no WSL account lanes.
Linked Issue
Internal test-box safety; no issue.
Visual Proof
N/A. This is an internal environment variable with no UI.
Unset: resolveSpawn output is identical for a wsl.exe call and a non-wsl call, and nothing is refused.
Allowlisted: every distro-targeting form is allowed, case-insensitively, and guest arguments after --exec are ignored.
List, status and version calls are exempt.
Not allowlisted: other distros, no-distro forms, ids and --shutdown are refused, matched by basename in any case.
Malformed: every distro is refused and the warning logs once.
resolveSpawn, spawnProcess and runProcessSync throw, and runProcess rejects with the code.
src/main/wsl.test.ts: discovery still lists every distro, an excluded distro's home probe resolves null like any failed probe, and an allowed distro still works.
native-pty-spawn-windows.test.ts: a refused WSL pane falls back past the excluded distro to an allowed one, and with no fallback it rejects without node-pty ever being called.
local-pty-runtime-spawn-wsl-allowlist.test.ts: the degraded main path never hands an excluded distro to node-pty, and unset passes through unchanged.
wsl-command-resolution-allowlist.test.ts:
Unset: resolveCommand output is identical to output with the distro allowlisted, for a UNC git call, a gh login-shell call and a Windows-host call, and it doesn't throw.
Set: a WSL resolution into another distro is refused, and a Windows-host one is not.
gitExecFileSync, gitSpawn and wslAwareSpawn refuse before execFileSync/spawn is called.
Removing the check makes the refusal cases fail.
wsl-distro-allowlist.test.ts also covers the scan stopping at the first positional argument: ls -d Allowed, -u root ls -d Allowed and --cd /tmp sh … -d Allowed are refused. This case fails without the fix.
check-process-host-imports.test.mjs: unguarded 'wsl.exe' and resolveWslExecutablePath() execs are flagged. Guarded ones, unrelated execs, comment-only mentions, tests and config/scripts are not. Removing a real guard (the watcher's) makes the checker fail.
filesystem-watcher-wsl.test.ts now asserts the process-host spawn spec.
Local checks (under the load rule): pnpm tc, typecheck:ci, check:code-quality:changed, check:process-host-imports (108 legacy importers, down one now that the watcher uses process-host), oxlint and the touched tests all pass (25 files, 232 tests on this round).
git-admission-storm-measurement.test.ts times out locally with or without this change, at load ~100. It measures real child timing.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Touches terminal spawn, so this needs two reviewers.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Unset is a no-op on every platform. SSH is unaffected: the check only matches a wsl/wsl.exe program on the machine running it.
Follow-up PR: move the remaining inline-checked calls (codex-accounts, the git-read probe, the Codex hook canonicalization, CLI sign-in) onto process-host so they no longer need their own check.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
The changes add a WSL distro allowlist guard and apply it before process-host and application code launches WSL commands. The guard parses configured distro names and rejects commands that do not meet the allowlist rules. WSL watcher creation now uses a process-host spawn helper, and an import check detects unguarded direct WSL execution. Tests cover guard behavior and its integration across the affected paths.
Priority: Low
Merge Risk: Moderate · up to fff84
The internal WSL distro allowlist does not cover Git operations that spawn wsl.exe directly. On a box with the allowlist enabled, Git actions can still start excluded distros. Guard those spawn sites and extend the import check before merging. Behavior is unchanged when the allowlist is unset.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the primary change: adding an internal WSL distro allowlist to prevent executions in unrelated distros on shared test machines.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description includes all template sections and clearly explains the change, rationale, scope, testing, risks, and checklist status. It documents that no issue is linked because this is an internal…
Full details: Description check
Explanation
The description includes all template sections and clearly explains the change, rationale, scope, testing, risks, and checklist status. It documents that no issue is linked because this is an internal test-box safety change, which is consistent with the template's maintainer exception. Automated testing and local validation results are provided.
Full details: Docstring Coverage
Explanation
Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 17 functions across 20 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Supported by static analysis
Script executed:
sed -n '1,180p' src/main/automations/workspace-provenance.ts
sed -n '175,250p' src/renderer/src/hooks/automation-dispatch-workspace.ts
sed -n '1,100p' src/renderer/src/store/slices/worktrees/create/host-planned-agent-launch.ts
sed -n '1,85p' src/renderer/src/store/slices/worktrees/create/runtime-provisioned-root-adoption.ts
set -o pipefail
nl -ba src/renderer/src/runtime/runtime-rpc-environment-call.ts | sed -n '1,180p'
rg -n -F --glob '*.ts' -e 'runtimeEnvironments.call' -e 'callRuntimeEnvironmentWithRevision' src/renderer/src/runtime/runtime-rpc-environment-call.ts src/main | head -100
Repository: stablyai/orca
Length of output: 1847
Keep automationProvenanceRequest local to desktop IPC.
The automation token is minted in desktop main and stored in a module-local map. A distinct runtime receives the request through window.api.runtimeEnvironments.call, then worktree.create calls resolveAutomationWorkspaceProvenance. Its beginAutomationDispatchTokenUse lookup cannot find the desktop token, so the valid request is rejected before creation.
ORCA_INTERNAL_WSL_DISTRO_ALLOWLIST (comma-separated distro names) keeps every
wsl.exe call out of distros not on the list: process-host's resolveSpawn,
the main and daemon node-pty spawns, and the two codex-accounts calls that
bypass process-host. Pure list/status/version calls stay allowed; any other
form must name an allowlisted distro, and --shutdown or a default-distro exec
is refused. A malformed value refuses every distro and logs once. Unset, the
check reads the variable and returns, so behavior is identical to today.
…lowlist
- Restore #34525's worktree-create payload and captured-host test, reverted by
accident in the first commit.
- Check the allowlist in execFileCapture, the choke point for WSL Git, gh and
worker-thread captures, and before the WSL git-read probe, the Codex hook
path canonicalization and the CLI login spawn. The WSL watcher now spawns
through process-host.
- Stop scanning wsl.exe argv at the first positional argument, which wsl.exe
runs in the default distro.
- check-process-host-imports fails on any direct wsl.exe exec outside
process-host that does not call assertWslDistroAllowed.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…e wsl.exe form
Every Git, gh and glab path into a distro resolves through resolveCommand, so
gitExecFileSync, gitSpawn, git stream reads and wslAwareSpawn are covered too;
the execFileCapture check is now redundant and removed. The import check also
treats buildWslExecArgs as a wsl.exe exec and accepts resolveCommand as covered.
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
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.
ELI5
Automated test runs on a shared Windows test machine must not touch the owner's personal WSL distros. This adds an internal switch, the environment variable
ORCA_INTERNAL_WSL_DISTRO_ALLOWLIST. When it is set, Orca refuses to run anything inside a distro that is not on the list.User risk: none when the variable is unset. Users never set it. When it is unset, the check reads the variable and returns before looking at anything else, so every spawn behaves exactly as it does today.
What Changed
ORCA_INTERNAL_WSL_DISTRO_ALLOWLISTis a comma-separated list of distro names, matched case-insensitively, for exampleorca-d3-sd,orca-d3-plain. One pure check,assertWslDistroAllowedin@orca/process-host/wsl-distro-allowlist, runs before every wsl.exe exec Orca's own code makes:resolveSpawn. EveryrunProcess,runProcessSyncandspawnProcesscall passes through it, including the daemon's and the CLI's. That covers startup probes, distro discovery, home probes, the WSL host transport, the hook relay, preflight, early wake, retries and fallbacks. The WSL file watcher now spawns through process-host too (wsl-watcher-spawn.ts), so it is covered here.resolveCommand(src/main/git/command-runner/wsl-command-resolution.ts). This is the single point where every Git, gh and glab path gets itswsl.exe -d <distro> …form. The check runs there, before the distro is noted as launched. So every spawn API that later runs the result is covered:execFileCapture(main and worker thread),gitExecFileSync,gitSpawn, the git stream reads,wslAwareSpawn,spawnCommandCaptureand the process-host paths. Windows-host resolutions are never checked. With the variable unset, resolveCommand neither throws nor changes its output.local-pty-runtime-spawn.ts);spawnNativeDaemonPty. This is checked before the macOS TCC and terminal-scope wrappers, so the real wsl.exe argv is what gets checked.child_processwsl.exe calls, each checked inline before its exec:execFileSyncand the loginspawn;rejected;unavailableasynchronously;src/cli/handlers/account.ts).check:process-host-importsnow fails on any non-test file undersrc/, outside process-host, that importschild_process, builds a wsl.exe exec ('wsl.exe',resolveWslExecutablePath()orbuildWslExecArgs()), and neither callsassertWslDistroAllowednor takes its program fromresolveCommand,resolveGitCommandorresolveDefaultWslCli(checked centrally). config/scripts is exempt. It reports nothing on the current tree.Rules while the variable is set (program basename
wslorwsl.exe, any case):-l/--list,-v,-q,--running,--all,-o/--online,--status,--version,--help), so discovery can still list distros and filter them.-d/--distribution,-t/--terminateand--unregister.--distribution-idtakes an id, not a name, so it is always refused.--shutdown, and any call that names no distro before its command starts, since that would run in the default distro.--exec,-e,--, or the first positional argument. wsl.exe treats its first non-option argument as a command for the default distro, sowsl ls -d Allowedis refused. Anything after that point is the guest command and is not inspected.[A-Za-z0-9._-]): every distro is refused, list calls still work, and Orca logs once.A refusal throws an error with code
ORCA_WSL_DISTRO_NOT_ALLOWLISTEDbefore any child process starts.runProcessrejects, so async callers fall into their existing failure, retry and fallback handling. For example, the home probe resolvesnull, and the error is not classified as a transient WSL failure, so nothing retries in a loop.spawnProcessandrunProcessSyncthrow synchronously.orcad-windows-prebuild-cache.mjsnow lists the new file among its cache inputs, sincespawn-resolution.tsimports it.Why
There is no single process boundary, so the same pure function runs at each place Orca starts a process in a distro, rather than several parallel implementations. process-host and
resolveCommandtogether cover nearly every Windows spawn. The few remaining direct child_process calls are checked inline, and the import check keeps a new one from slipping in unchecked.Unset costs nothing new:
assertWslDistroAllowedreads the variable and returns before any argv work, at every call site. The string-argv split for node-pty's Windows command line happens inside the check, after that return.Out of scope, on purpose. An exec allowlist only governs Orca's own
wsl.exeinvocations. It can't stop:bash.exe(System32),wslg.exe,wslconfig.exe, and per-distro launchers such asubuntu.exe;wslstarted throughcmd.exeorpowershell.exe;wsltyped by a user in an Orca terminal.--remote wsl+<distro>(VS Code, Cursor and the like): the editor starts the distro itself, outside Orca's exec path.Any
\\wsl.localhost\<distro>\…or\\wsl$\<distro>\…read or write from Windows can boot or modify a distro without running wsl.exe. That includes file reads and writes, Windows Git on a UNC repo (including git maintenance and the direct-Git fallback), the restore-cwd probe, search and WSL account lanes. Verify runs on shared boxes must therefore use a clean profile with no saved UNC projects and no WSL account lanes.Linked Issue
Internal test-box safety; no issue.
Visual Proof
N/A. This is an internal environment variable with no UI.
Testing
src/packages/process-host/src/wsl-distro-allowlist.test.ts:resolveSpawnoutput is identical for a wsl.exe call and a non-wsl call, and nothing is refused.--execare ignored.--shutdownare refused, matched by basename in any case.resolveSpawn,spawnProcessandrunProcessSyncthrow, andrunProcessrejects with the code.src/main/wsl.test.ts: discovery still lists every distro, an excluded distro's home probe resolvesnulllike any failed probe, and an allowed distro still works.native-pty-spawn-windows.test.ts: a refused WSL pane falls back past the excluded distro to an allowed one, and with no fallback it rejects without node-pty ever being called.local-pty-runtime-spawn-wsl-allowlist.test.ts: the degraded main path never hands an excluded distro to node-pty, and unset passes through unchanged.wsl-command-resolution-allowlist.test.ts:resolveCommandoutput is identical to output with the distro allowlisted, for a UNC git call, a gh login-shell call and a Windows-host call, and it doesn't throw.gitExecFileSync,gitSpawnandwslAwareSpawnrefuse beforeexecFileSync/spawnis called.wsl-distro-allowlist.test.tsalso covers the scan stopping at the first positional argument:ls -d Allowed,-u root ls -d Allowedand--cd /tmp sh … -d Allowedare refused. This case fails without the fix.check-process-host-imports.test.mjs: unguarded'wsl.exe'andresolveWslExecutablePath()execs are flagged. Guarded ones, unrelated execs, comment-only mentions, tests and config/scripts are not. Removing a real guard (the watcher's) makes the checker fail.filesystem-watcher-wsl.test.tsnow asserts the process-host spawn spec.Local checks (under the load rule):
pnpm tc,typecheck:ci,check:code-quality:changed,check:process-host-imports(108 legacy importers, down one now that the watcher uses process-host), oxlint and the touched tests all pass (25 files, 232 tests on this round).git-admission-storm-measurement.test.tstimes out locally with or without this change, at load ~100. It measures real child timing.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Touches terminal spawn, so this needs two reviewers.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)