Skip to content

fix(ssh): launch the Windows relay outside sshd's job so standard users work - #24224

Merged
OrcaWin merged 5 commits into
mainfrom
OrcaWin/node-rt-win-std-launch
Oct 1, 2026
Merged

OrcaWin merged 5 commits into
mainfrom
OrcaWin/node-rt-win-std-launch

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​497 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​494
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​982 $\color{#cf222e}{\Huge{\mathbf{−}}}$​161 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​821

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

  • Native launcher: spawnOutsideJob, added via the @vscode/windows-process-tree patch in process_launch.cc. It makes one CreateProcessW call with CREATE_BREAKAWAY_FROM_JOB | CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW.
    • An explicit handle list passes only NUL stdin and the relay's log files, so the relay never inherits an SSH channel pipe.
    • Win32-OpenSSH creates session jobs with BREAKAWAY_OK in every version from 2018 to current: inbox 8.1 and 9.5, and preview 10.x.
  • Relay launcher mode: relay.js --windows-breakaway-launch starts the relay, prints one ORCA_RELAY_LAUNCH line and exits.
    • Exit 3 means breakaway isn't available, and only then does WMI run.
    • If WMI is also refused, the error names the standard-user limit.
  • Shared path: the pinned and host-Node relays both go through launchWindowsRelay.
  • Runtime-store GC: when WMI refuses, GC falls back to matching Get-Process image paths (by path, never by process name). Without this, cleanup kept every runtime.
  • CI lanes: the WMI grant is removed, as the owner decided. A launch that needs WMI now fails its cell, and each launched cell must report {method: 'breakaway', inJob: false} exactly once.
  • Docs: windows-edr-posture.md has a new section on this. There's no Add-Type, no -ExecutionPolicy, no scheduled task, and no new -EncodedCommand site.

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:

    • The PR run of the Windows desktop build, which compiles the patched addon against Electron headers, hasn't happened yet.
    • The default legacy runtime only gets breakaway when windows-process-tree.node is 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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Adds Windows relay launcher addon to build and deployment pipeline.

The PR is not yet safe to merge because a relay reported inside the SSH job can still be treated as successfully detached.

Findings

  1. P1 Child inside job accepted ▶

Summary

The PR adds a Windows relay breakaway launcher and packages its native addon for desktop builds. Since the previous review, it also adds macOS loopback-sshd cells to exercise pinned-runtime deployment and reconnect behavior.

  • The earlier missing-addon thread is resolved.
  • The earlier finding that accepts a child still inside the SSH job remains outstanding.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Windows SSH deploy] --> B[Relay launcher]
  B --> C{Breakaway available?}
  C -->|Yes| D[Start relay outside SSH job]
  C -->|No| E[Try WMI fallback]
  D --> F[Reconnect to relay]
Loading

Reviews (5) · Last reviewed commit: "test(ci): find the mac orcad-template do..."

Comment on lines +121 to +125
if (result.ok) {
return {
report: { method: 'breakaway', pid: result.pid, inJob: result.inJob },
exitCode: RELAY_WINDOWS_BREAKAWAY_EXIT_CODES.launched
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Child inside job accepted

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:

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one classification rough edge inline, plus a rollout note to confirm before merge.

Reviewed changes

  • Native spawnOutsideJob (new src/process_launch.cc + header in the @vscode/[email protected] patch): one CreateProcessW with CREATE_BREAKAWAY_FROM_JOB and a PROC_THREAD_ATTRIBUTE_HANDLE_LIST of 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-launch runs the addon once, prints one ORCA_RELAY_LAUNCH {json} report, and exits 0/1/3; loadSpawnOutsideJob degrades to addon-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 exit 3, ORCA_RELAY_LAUNCH_REFUSED classified into a named error, and the last report line logged by the deploy.
  • Runtime-store GC fallback (remote-node-runtime-store-windows.ts): Get-Process image-path match when the Get-CimInstance hold query is refused, still by path and never by ProcessName.
  • 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.md documents 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?

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.yml compiles both arches on windows-2022 and uploads the relay-windows-process-tree artifact. release-cut, hourly-mac-build, daily-mac-build, adhoc-mac-build and the dispatched release-mac-build (cross-run via release_run_id) download it into .build/windows-process-tree and set ORCA_REQUIRE_RELAY_NATIVE_ADDONS: x64,arm64.
  • Staging + validation — new config/scripts/relay-windows-process-tree-staging.mjs checks each staged binary's PE machine, the missing ReadProcessMemory import, and the spawnOutsideJob export; a required arch failing any check fails the build, an unrequired one degrades to the PowerShell scan. build-relay.mjs now uses it in place of the inline stageWindowsProcessTreeAddon; build-windows-process-tree-relay-addon.mjs asserts the launcher export after node-gyp.
  • Contract tests — new relay-windows-process-tree-workflow-contract.test.mjs pins each packaging workflow's download/provider ordering and the requirement env; hourly-preflight-workflow.test.mjs and release-cut-token-permissions.test.mjs updated.

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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-relay-epipe branch from 5063e96 to 3ff605b Compare October 1, 2026 10:28
@OrcaWin
OrcaWin requested a review from brennanb2025 as a October 1, 2026 10:28
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-win-std-launch branch from c185372 to 569d673 Compare October 1, 2026 10:28
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-relay-epipe branch from 3ff605b to 234cc8c Compare October 1, 2026 11:05
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-win-std-launch branch from baafb5e to 21cb1ef Compare October 1, 2026 11:06
m4air added 5 commits October 1, 2026 04:43
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.
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-win-std-launch branch from 21cb1ef to 9a8f17a Compare October 1, 2026 11:44
@OrcaWin
OrcaWin changed the base branch from OrcaWin/node-rt-relay-epipe to main October 1, 2026 11:44
@OrcaWin OrcaWin closed this Oct 1, 2026
@OrcaWin OrcaWin reopened this Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8968195c-ca40-440f-9982-7aee2147a62b

📥 Commits

Reviewing files that changed from the base of the PR and between f9940d5 and 9a8f17a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (30)
  • .github/workflows/adhoc-mac-build.yml
  • .github/workflows/daily-mac-build.yml
  • .github/workflows/hourly-mac-build.yml
  • .github/workflows/relay-windows-process-tree.yml
  • .github/workflows/release-cut.yml
  • .github/workflows/release-mac-build.yml
  • .github/workflows/ssh-windows-hosts.yml
  • config/ci/windows-ssh-provider/invoke-pinned-relay-cells.ps1
  • config/patches/@[email protected]
  • config/scripts/build-relay.mjs
  • config/scripts/build-windows-process-tree-relay-addon.mjs
  • config/scripts/hourly-preflight-workflow.test.mjs
  • config/scripts/orcad-template-release-workflow.test.mjs
  • config/scripts/relay-windows-process-tree-staging.mjs
  • config/scripts/relay-windows-process-tree-staging.test.mjs
  • config/scripts/relay-windows-process-tree-workflow-contract.test.mjs
  • config/scripts/release-cut-token-permissions.test.mjs
  • config/scripts/windows-process-tree-gyp-rebuild.mjs
  • docs/reference/windows-edr-posture.md
  • docs/reference/windows-process-enumeration.md
  • src/main/ssh/remote-node-runtime-store-windows.test.ts
  • src/main/ssh/remote-node-runtime-store-windows.ts
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/ssh/ssh-relay-windows-host-lane.test.ts
  • src/main/ssh/ssh-relay-windows-launch-command.test.ts
  • src/main/ssh/ssh-relay-windows-launch-command.ts
  • src/relay/relay-windows-breakaway-launch.test.ts
  • src/relay/relay-windows-breakaway-launch.ts
  • src/relay/relay.ts
  • src/shared/relay-windows-breakaway-launch.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The 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 Get-Process. The changes also update workflow and launch tests, Windows SSH-host diagnostics, and reference documentation.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 9a8f1

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 Review

Security architecture risk: 🔵 Low · up to 9a8f1

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The launch change affects processes on the selected Windows SSH host through the authenticated caller's execution context, rather than demonstrating machine-wide privilege gain. The native build dependency has broader distribution scope because desktop packages stage Windows relay binaries; downstream hosts therefore inherit trust in the configured build ref and artifact-producing run.

Trust Boundaries and Controls

  • observed — The native launcher supplies only NUL stdin and its newly opened stdout/stderr files through an explicit inherited-handle list. Both launch routes retain the credential-file argument, and connection still enters the existing credential-reading connect mode. Launch-report text is logged rather than used to authorize connection.

Resilience and Maintainability Implications

  • inferred — The deployment caller can abandon readiness waiting without explicitly terminating the detached child by PID. Startup exceptions exit the relay, but termination of a child hung before binding and single-owner behavior during simultaneous retries remain unverified. The prior WMI route also detached the process, so this is not established as a newly introduced lifecycle failure.

Hardening Proposals

  • proposed — Validate bounded pre-bind startup and single-owner behavior under cancellation, timeout, and simultaneous retries. If no existing owner guarantees termination, consider a bounded startup lease rather than treating successful process creation as completed recovery.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: launching the Windows relay outside sshd's job so standard users can use SSH hosts.
Description check ✅ Passed The description is mostly complete and directly covers the user impact, implementation, rationale, linked issue, visual proof, testing, and known pre-merge limitations. It omits the Review, Notes, and…
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant