Repository navigation
fix(ssh): launch the Windows relay outside sshd's job so standard users work - #24224
Conversation
|
| if (result.ok) { | ||
| return { | ||
| report: { method: 'breakaway', pid: result.pid, inJob: result.inJob }, | ||
| exitCode: RELAY_WINDOWS_BREAKAWAY_EXIT_CODES.launched | ||
| } |
There was a problem hiding this comment.
If CreateProcessW succeeds but the child is still in a job, the native result has ok: true and inJob: true. This branch nevertheless returns exit 0, so deployment treats the launch as a successful breakaway and does not try the WMI fallback. The relay may answer the initial pipe check but be killed when the SSH session ends, losing the reconnectable relay state.
Knowledge Base Used:
There was a problem hiding this comment.
ℹ️ No critical issues — one classification rough edge inline, plus a rollout note to confirm before merge.
Reviewed changes
- Native
spawnOutsideJob(newsrc/process_launch.cc+ header in the@vscode/[email protected]patch): oneCreateProcessWwithCREATE_BREAKAWAY_FROM_JOBand aPROC_THREAD_ATTRIBUTE_HANDLE_LISTof only NUL-stdin and the two log files, so the relay leaves sshd's job without inheriting an SSH channel pipe. - Relay launcher mode (
src/relay/relay-windows-breakaway-launch.ts,relay.ts):--windows-breakaway-launchruns the addon once, prints oneORCA_RELAY_LAUNCH {json}report, and exits0/1/3;loadSpawnOutsideJobdegrades toaddon-missing/addon-predates-launcher. - Launch script + report contract (
src/main/ssh/ssh-relay-windows-launch-command.ts,src/shared/relay-windows-breakaway-launch.ts,ssh-relay-deploy.ts): launcher first, WMI only on exit3,ORCA_RELAY_LAUNCH_REFUSEDclassified into a named error, and the last report line logged by the deploy. - Runtime-store GC fallback (
remote-node-runtime-store-windows.ts):Get-Processimage-path match when theGet-CimInstancehold query is refused, still by path and never byProcessName. - CI + docs: lanes now build the relay addon and run with no WMI grant, asserting exactly one
{method:'breakaway', inJob:false}launch;windows-edr-posture.mddocuments the new route.
I verified the PowerShell $LASTEXITCODE/-join capture, the --relay-args argv round-trip, the last-line report selection, and the native handle-list semantics against Microsoft Learn; those are correct.
ℹ️ The fix reaches standard users only if the win32 relay carries the addon
The native launcher is optional in RELAY_ARTIFACTS and only a Windows build machine can compile it, so a relay deployed without it falls back to WMI — which is exactly the route that failed for standard users. The PR description flags this as open; worth confirming the release path ships windows-process-tree.node in the win32 relay for every desktop platform's installer before this lands, and that removing the CI WMI grant intentionally leaves the fallback route shape-tested only (no lane exercises it end-to-end).
Technical details
# Rollout dependency for the breakaway launcher
## Affected sites
- `src/shared/relay-artifacts.ts:74` — `windows-process-tree.node` is `{windowsOnly: true, optional: true}`, so `stageWindowsProcessTreeAddon` skips it on a non-Windows build host.
- `config/scripts/build-relay.mjs:95-113` — a build on macOS/Linux logs "relay will use the PowerShell scan" and emits the win32 relay without the addon.
- `config/ci/windows-ssh-provider/invoke-pinned-relay-cells.ps1` — the WMI grant was removed, so the fallback no longer has lane coverage.
## Open questions for the human
- Does the release pipeline guarantee the win32 relay artifacts in *every* published installer (mac/linux legs) contain the addon produced on the win leg?
- Is the WMI fallback expected to retain any end-to-end coverage, or is shape-only unit coverage accepted?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| + if (!created) { | ||
| + BOOL caller_in_job = FALSE; | ||
| + IsProcessInJob(GetCurrentProcess(), nullptr, &caller_in_job); | ||
| + const bool denied = create_error == ERROR_ACCESS_DENIED && caller_in_job; |
There was a problem hiding this comment.
IsProcessInJob(GetCurrentProcess(), nullptr, …) only reports whether the caller is in any job — not whether that job set JOB_OBJECT_LIMIT_BREAKAWAY_OK. So every ERROR_ACCESS_DENIED while in a job (an EDR/AppLocker block, or an image ACL — the managed-host scenario this PR targets) is labeled breakaway-denied, which makes the launch script try the EDR-scored WMI Create and then report a misleading "this account cannot start a process that outlives the SSH session". Since Win32-OpenSSH's session job always sets BREAKAWAY_OK, the real breakaway refusal is rare, so the label mostly fires for non-breakaway denials.
Technical details
# breakaway-denied over-classification
## Affected sites
- `config/patches/@[email protected]` (new `src/process_launch.cc` lines 550-555) — `const bool denied = create_error == ERROR_ACCESS_DENIED && caller_in_job;`
- Consumed by `src/relay/relay-windows-breakaway-launch.ts:129` (`result.reason === 'breakaway-denied'` → `unavailable` → WMI fallback) and surfaced by the `ORCA_RELAY_LAUNCH_REFUSED` message in `ssh-relay-windows-launch-command.ts:88`.
## Required outcome
- `breakaway-denied` should mean the job actually refuses breakaway, so a denial from another cause does not trigger a WMI retry or assert the wrong cause in the error.
## Suggested approach (optional)
- Query `QueryInformationJobObject(…, JobObjectExtendedLimitInformation, …)` for `JOB_OBJECT_LIMIT_BREAKAWAY_OK` (or `SILENT_BREAKAWAY_OK`) and only then label `breakaway-denied`; otherwise return `failed`.
- If the extra call is not worth it, keep the WMI fallback but stop claiming the standard-user cause unless the job limit was actually inspected.There was a problem hiding this comment.
ℹ️ Incremental changes look good; the one prior finding remains open, so this stays non-approving.
Reviewed changes (incremental, 72047c0e → c185372d)
- Packaging the launcher addon for every desktop package — new reusable
.github/workflows/relay-windows-process-tree.ymlcompiles both arches onwindows-2022and uploads therelay-windows-process-treeartifact.release-cut,hourly-mac-build,daily-mac-build,adhoc-mac-buildand the dispatchedrelease-mac-build(cross-run viarelease_run_id) download it into.build/windows-process-treeand setORCA_REQUIRE_RELAY_NATIVE_ADDONS: x64,arm64. - Staging + validation — new
config/scripts/relay-windows-process-tree-staging.mjschecks each staged binary's PE machine, the missingReadProcessMemoryimport, and thespawnOutsideJobexport; a required arch failing any check fails the build, an unrequired one degrades to the PowerShell scan.build-relay.mjsnow uses it in place of the inlinestageWindowsProcessTreeAddon;build-windows-process-tree-relay-addon.mjsasserts the launcher export afternode-gyp. - Contract tests — new
relay-windows-process-tree-workflow-contract.test.mjspins each packaging workflow's download/provider ordering and the requirement env;hourly-preflight-workflow.test.mjsandrelease-cut-token-permissions.test.mjsupdated.
This closes the rollout gap from the prior review: the win32 relay now carries the addon in every platform's installer, so standard users no longer depend on a Windows-built package. I confirmed the range-diff didn't distort the tree — build-relay.mjs has a single staging call, release-cut.yml a single ORCA_REQUIRE_RELAY_NATIVE_ADDONS, and no duplicate job keys. The new tests pass locally. Not flagged: ssh-relay-deploy-pinned-node.test.ts's "rung A refusal" case fails in this environment but is unrelated to this PR (it exercises ssh-relay-runtime-resolution.ts).
The native breakaway-denied over-classification raised in the previous review is unchanged (no new commits touch process_launch.cc); it remains the one outstanding item on the PR.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
5063e96 to
3ff605b
Compare
c185372 to
569d673
Compare
3ff605b to
234cc8c
Compare
baafb5e to
21cb1ef
Compare
Win32-OpenSSH kills a session's job on close but allows breakaway. relay.js gains a one-shot launcher mode that starts the detached relay with CREATE_BREAKAWAY_FROM_JOB through the staged process-tree addon, so a standard user no longer needs a WMI Remote Enable grant. WMI stays as the fallback for a relay without the addon, and a refusal there is named. The Windows SSH-host lanes drop their WMI grant and assert the breakaway route and adoption.
The store GC read held runtimes through Get-CimInstance Win32_Process, which WMI refuses to a standard user's SSH logon, so the pass kept every runtime. On a refusal it now reads this account's own process image paths through Get-Process.
…package macOS and Linux packages carried Windows relays without windows-process-tree.node, so a legacy-runtime relay they uploaded to a Windows SSH host could not launch outside sshd's job and fell back to WMI, which a standard user is refused. A reusable Windows job now compiles the x64 and arm64 addons once and uploads them; release-cut, release-mac-build, and the hourly/daily/adhoc mac builds download them before build:release and require both arches. Staging now rejects a binary with the wrong PE machine, the ReadProcessMemory import, or no spawnOutsideJob export, so a stale pre-launcher build cannot ship.
…uild scripts change The staging and gyp-rebuild scripts decide which windows-process-tree addon the relay ships, so a change to either must re-prove the Windows host cells.
The release mac job now also downloads the relay Windows process-tree addons, so the first download-artifact step is no longer the template's.
21cb1ef to
9a8f17a
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (30)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe changes add a reusable Windows workflow that builds process-tree addons for x64 and arm64 and makes desktop packaging jobs retrieve and require those artifacts. Windows relay startup can use the addon to launch outside the SSH job, report the result, and use WMI when breakaway launch is unavailable. Windows runtime-store inventory falls back from a failed CIM query to Priority: ➖ Normal Merge Risk: 🔵 Low · up to The change is mergeable with bounded owner awareness: unrelated Windows launch denials can trigger an unnecessary WMI retry and misleading refusal message. Correct the denial classification as a follow-up. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change enables standard Windows accounts to keep remote sessions running after SSH disconnects without showing privilege elevation. Interrupted startup and native-binary delivery still need validation. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 35.48% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 19 files. (11 skipped: 11 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |

ELI5
Windows SSH hosts only worked for admin accounts. Orca started the relay through WMI so it would outlive the SSH session, and Windows refuses WMI process creation to standard users. The relay is now started directly outside the SSH session's job, which OpenSSH allows. WMI is only a fallback.
What Changed
spawnOutsideJob, added via the@vscode/windows-process-treepatch inprocess_launch.cc. It makes oneCreateProcessWcall withCREATE_BREAKAWAY_FROM_JOB | CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW.BREAKAWAY_OKin every version from 2018 to current: inbox 8.1 and 9.5, and preview 10.x.relay.js --windows-breakaway-launchstarts the relay, prints oneORCA_RELAY_LAUNCHline and exits.launchWindowsRelay.Get-Processimage paths (by path, never by process name). Without this, cleanup kept every runtime.{method: 'breakaway', inJob: false}exactly once.windows-edr-posture.mdhas a new section on this. There's noAdd-Type, no-ExecutionPolicy, no scheduled task, and no new-EncodedCommandsite.Why
Standard users are the normal case on managed Windows servers.
Linked Issue
Part of the Node runtime plan (Phase 2). Stacked on #24209.
Visual Proof
N/A. This changes remote host setup.
Testing
Windows host lanes (run 36773730686): all 4 jobs green, x64 and arm64, each with inbox and preview OpenSSH. Standard-user WMI was denied in every job, and every cell launched via breakaway. The reconnect reused the relay.
Unit tests: the launch command, the launcher mode and the GC fallback.
Open before merge:
windows-process-tree.nodeis in the relay folder. Only Windows builds produce it, so macOS and Linux desktop packages need it shipped as a release artifact.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.