Skip to content

feat(ssh): pinned-Node relay on Windows SSH hosts - #24135

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/node-rt-p2-windows
Oct 1, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/node-rt-p2-windows

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​566 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​554
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​516 $\color{#cf222e}{\Huge{\mathbf{−}}}$​131 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​385

ELI5

Windows SSH hosts that opt into "Orca-managed Node" now get the pinned node.exe plus Orca's prebuilt ConPTY terminal addons, instead of falling back to the host's own Node.

What Changed

  • Runtime store on Windows (orcad-remote-node-runtime-windows.ts):
    • Probe runtimes\node-<sha>\node.exe with Get-FileHash, then upload the official node-v24.21.0-win-<arch>.zip.
    • One promote invocation checks the archive hash, extracts with tar.exe (Expand-Archive as a fallback), hashes and runs node.exe --version, and publishes with a single directory move plus .verified.
    • node.exe keeps its real name.
    • Every step is one existing powerShellCommand call: no new -EncodedCommand site, no -ExecutionPolicy, no Add-Type.
  • Relay: uploads the win32 slot (conpty.node, conpty.dll/OpenConsole.exe, the console-list addon), the watcher and windows-process-tree, then launches on node.exe. The self-test opens a PTY with the bundled ConPTY.
  • Tampering: a hash change after the write is reported as "security software removed or modified".
  • Targets: ORCAD_TEMPLATE_TARGETS now includes the win32 targets.

Why

This is design D5 (Windows). Keeping the official signed node.exe under its real name and one stable path is the least suspicious setup for endpoint security software.

Linked Issue

Part of the Node runtime plan (Phase 2). Stacked on #24129.

Visual Proof

N/A. This changes remote host setup, with no UI.

Testing

  • Command construction and path.win32 handling have unit tests.

  • Fixed in review: a redundant powershell.exe stage cleanup is removed.

  • Not yet run on a real Windows host. Next step: the Windows SSH provider harness (config/ci/windows-ssh-provider on OrcaWin/np-windows-ssh-provider-diagnostic), on Win32-OpenSSH preview and inbox, x64 and ARM64.

  • Follow-ups:

  • 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: 3/5

[High risk] Adds Windows support to the pinned Node runtime deployment system.

The PR does not yet appear safe to merge because a Windows runtime refusal can block an otherwise usable host-Node connection, and stale refusals can skip a valid pinned runtime.

Findings

  1. P2 Interrupted uploads leave archives behind ▶

Summary

The PR adds a pinned Windows Node runtime and prebuilt relay addons, and extends SSH deployment with a persisted fallback ladder, runtime settings, and telemetry.

  • Windows promotion verifies the uploaded runtime before publishing it.
  • The new ladder has a Windows fallback failure and can retain refusals across endpoint changes.
  • Telemetry deduplication can discard an event that was never sent.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Pinned Node A"] --> B["Compat runtime B"]
  B --> C["Host Node + prebuilt addons C"]
  C --> L["Host Node + npm"]
  L --> D["Unavailable D"]
  A -- "fresh noexec" --> D
Loading

Reviews (3) · Last reviewed commit: "test(ssh): expect the ladder's remembere..."

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Modified Node passes warm check src/main/ssh/orcad-remote-node-runtime-windows.ts:82 ▶

    On a reconnect with an already-installed Windows relay, this check returns READY when .verified and node.exe merely exist. If node.exe changed after installation, ensurePinnedRelayRuntime skips the hash-checking probe and launches the modified executable. Recheck its integrity before treating the runtime as ready.

  • P2 Missing files silently change ConPTY src/relay/relay-windows-conpty.ts:28 ▶

    If either bundled ConPTY file disappears after installation, this helper returns no useConptyDll option. Live terminals then use the system ConPTY even though the install self-test required the bundled files. That silent switch makes the tested terminal setup differ from the one users actually get.

@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 minor cleanup gap inline.

Reviewed changes

  • Windows runtime store (orcad-remote-node-runtime-windows.ts, new) — probe/present/promote as single powerShellCommand lines: hash the zip, extract node.exe via System32 tar.exe (Expand-Archive fallback), hash and run it, then publish with one [IO.Directory]::Move and a .verified marker; verified bytes that change later are reported as security software.
  • Shared verdict plumbing (orcad-remote-node-runtime-report.ts, new) — tokens plus assertRemoteNodeRuntimePromoted, RemoteNodeRuntimeSecurityModifiedError, and \r?\n-tolerant parseRemoteRuntimeExitReport; orcad-remote-node-runtime.ts re-exports them.
  • Host dispatch (orcad-remote-node-runtime.ts) — Windows branches for probe/present, wrapCommand: false on Windows, and the upload stage rides the probe to save a spawn; finally skips the cleanup exec on Windows via hostRemovedStage.
  • Plan/install (ssh-relay-pinned-node.ts, ssh-relay-pinned-node-install.ts) — drops the windows_host_unsupported refusal, resolves win32-* targets, adds windows-process-tree.node to the win32 addon list, maps a security-modified host verdict to the security_software refusal, and passes { host } into the self-test.
  • Self-test (ssh-relay-runtime-self-test.ts) — one-spawn Windows self-test that requires the report to name the pin, plus AV/AppLocker classification patterns and the new security_software refusal.
  • Relay side (relay-runtime-identity.ts, relay-windows-conpty.ts, pty-handler.ts) — recognizes runtimes\node-<sha>\node.exe as pinned-node and opts only a pinned win32 relay into the bundled ConPTY DLL; the self-test looks for conpty.node and refuses a quarantined pair.
  • Template targets (src/shared/node-runtime-pin.ts) — ORCAD_TEMPLATE_TARGETS now includes the win32 targets.

Verified locally: the 7 touched/related suites pass (91 tests) and pnpm tc:node is clean. Two independent lenses (publish/marker invariant and relay runtime-kind/ConPTY parity) found no defect on the Windows pinned path.

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

Comment on lines +193 to +197
const probe = await exec(
conn,
host,
windows
? windowsNodeRuntimeProbeCommand(runtimeDir, target, stageDir)

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.

On Windows the probe itself creates the upload stage (New-Item in windowsNodeRuntimeProbeCommand), but this exec sits above the try, so if it rejects (abort, dropped channel, or the 30 s default timeout) after New-Item has run, the .stage-node-<sha>-<token> directory is left under runtimes/ with nothing to remove it. The POSIX path does its mkdir inside the try, and runtime GC does not target .stage- dirs, so this is a Windows-only leak window.

Technical details
# Windows probe-created stage leaks when the probe exec fails

## Affected sites
- `src/main/ssh/orcad-remote-node-runtime.ts:193-200` — the probe `exec` (carrying `stageDir`) runs before the `try` at `:209`, so its `finally` (which calls `cleanupStage`) never runs on a probe failure.
- `src/main/ssh/orcad-remote-node-runtime-windows.ts:67-71` — `windowsNodeRuntimeProbeCommand` runs `New-Item -ItemType Directory -Force -Path <stageDir>` before printing `MISSING`.
- `src/main/ssh/orcad-remote-node-runtime.ts:217-218` — POSIX performs its `mkdir -p` inside the `try`, which is why POSIX has no equivalent window.

## Required outcome
- A probe that rejects must not leave the stage directory on the host.

## Suggested approach (optional)
- Create the Windows stage inside the `try` (accepting a second `powershell.exe` spawn), or wrap the probe in a `try/catch` that runs `windowsNodeRuntimeStageCleanupCommand(stageDir)` before rethrowing.

@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-p2-relay branch 2 times, most recently from 876e541 to b111d20 Compare October 1, 2026 08:11
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-p2-windows branch from 536d6b9 to 2eb9ff5 Compare October 1, 2026 08:45
@OrcaWin
OrcaWin changed the base branch from OrcaWin/node-rt-p2-relay to main October 1, 2026 08:52
@OrcaWin OrcaWin closed this Oct 1, 2026
@OrcaWin OrcaWin reopened this Oct 1, 2026
// A transfer that may still be writing keeps its stage; loss of contact is not an exit.
if (!stageUnconfirmed) {
await exec(`rm -rf ${shellEscape(stageDir)}`).catch(() => {})
if (!stageUnconfirmed && !hostRemovedStage) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Interrupted uploads leave archives behind

When an SSH transfer or promotion ends without confirmed remote termination, this guard leaves its upload directory on the host. Each retry creates a new directory, but runtime-store cleanup does not collect these directories. Repeated interrupted installs can therefore consume host disk space indefinitely.

m4air added 3 commits October 1, 2026 02:09
Windows hosts opted into remoteRuntime 'pinned-node' now get the same rung A
relay POSIX hosts do, instead of an early host-Node fallback.

- Runtime store: the official node-v24.21.0-win-<arch>.zip is uploaded to a
  stage under %USERPROFILE%\.orca-remote\runtimes, verified against the pinned
  archive hash, node.exe extracted with System32 tar.exe (Expand-Archive
  fallback), hashed with Get-FileHash, run once, and published with
  node.exe + .verified by one Directory.Move. One powershell.exe per phase via
  the existing powerShellCommand helper; the probe also creates the stage. No
  new -EncodedCommand site, no -ExecutionPolicy, no Add-Type. node.exe keeps
  its real name at runtimes\node-<sha>\node.exe.
- Bytes that change or vanish after Orca wrote and verified them are reported
  as ORCA_NODE_RUNTIME_SECURITY_MODIFIED and become a remembered
  'security_software' refusal (fallback to the host-Node relay); application
  control blocks classify as 'noexec'.
- Addons: the win32 slot's conpty.node, conpty_console_list.node,
  conpty\conpty.dll + OpenConsole.exe, watcher and windows-process-tree.node
  ride with the relay; the orcad template now carries the win32 targets.
- Self-test on Windows is one powershell.exe running relay.js on node.exe; the
  report must name the pinned Node. The relay self-test loads conpty.node and
  opens a PTY with useConptyDll, and reports a missing bundled ConPTY file as a
  load failure. A pinned relay's terminals use the bundled ConPTY too; host-Node
  relays are unchanged.
- describeRelayRuntime recognizes the Windows store layout.
…dows runtime promote

The promote script already removes its stage on every path, so the client-side
cleanup only runs when promote never returned (upload failure, abort, timeout).
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-p2-windows branch from 2eb9ff5 to 481a142 Compare October 1, 2026 09:10
@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.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

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: a4f0bdcb-d32f-44f3-9581-e413800f8390

📥 Commits

Reviewing files that changed from the base of the PR and between 53fd2de and 481a142.

📒 Files selected for processing (18)
  • src/main/ssh/orcad-remote-node-runtime-report.ts
  • src/main/ssh/orcad-remote-node-runtime-windows.test.ts
  • src/main/ssh/orcad-remote-node-runtime-windows.ts
  • src/main/ssh/orcad-remote-node-runtime.ts
  • src/main/ssh/ssh-relay-deploy-pinned-node.test.ts
  • src/main/ssh/ssh-relay-pinned-node-install.test.ts
  • src/main/ssh/ssh-relay-pinned-node-install.ts
  • src/main/ssh/ssh-relay-pinned-node.test.ts
  • src/main/ssh/ssh-relay-pinned-node.ts
  • src/main/ssh/ssh-relay-runtime-self-test.test.ts
  • src/main/ssh/ssh-relay-runtime-self-test.ts
  • src/main/ssh/ssh-relay-runtime-step-plan.ts
  • src/relay/pty-handler.ts
  • src/relay/relay-runtime-identity.ts
  • src/relay/relay-runtime-self-test.test.ts
  • src/relay/relay-runtime-self-test.ts
  • src/relay/relay-windows-conpty.ts
  • src/shared/node-runtime-pin.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

Windows hosts can now use pinned Node runtimes for relay deployment. The runtime installer uses PowerShell to probe, stage, verify, and promote the executable. Relay planning, runtime self-tests, and executable paths include Windows-specific handling. Relay runtime checks recognize Windows pinned-runtime paths, and PTY spawning enables bundled ConPTY support when its required files exist. POSIX runtime paths and commands remain supported.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 481a1

This adds Windows pinned-Node relay support, and the new PowerShell install and verify scripts have not yet run on a real Windows host. Run the planned Windows SSH harness before relying on it. The failure modes are bounded because the code falls back to host Node when the pinned runtime is refused.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 481a1

The initial Windows installation verifies Node, but later connections can accept a replaced copy without rechecking its contents. This requires write access to the remote installation; broader privilege escalation has not been established.

Retained concerns

  • Medium · security · observed: The new Windows warm-path check treats .verified plus node.exe existence as current runtime readiness. For an already-installed relay, this bypasses executable hashing and installation self-testing before the selected executable reaches Windows relay launch. Changed executable bytes can therefore be reused while retaining the verification marker. This requires write access to the remote runtime tree; no cross-account privilege escalation is demonstrated.
Security review details

Security Blast Radius

  • inferred — The supported attack scope is a Windows remote runtime tree accessible to a writer and the relay executions that reuse its pinned executable. Relay launches carry endpoint and credential-file parameters. The inspected evidence does not establish desktop compromise, cross-account access or fleet-wide propagation.

Security Findings and Attack Paths

  • inferred — A writer can replace a previously installed node.exe while leaving .verified intact. On a later connection with an installed relay, the presence check accepts that state, the installer returns early, and deployment passes the executable to Windows relay launch without the cold-path hash checks. The PR makes this path reachable on Windows, but does not demonstrate additional authority beyond the remote execution account.

Trust Boundaries and Controls

  • observed — The cold Windows flow checks the uploaded archive against its pin, hashes extracted node.exe before execution, requires the expected version and successful status, rechecks after execution, and checks published bytes before READY. These are substantive integrity controls, but they do not run on the accepted installed-relay warm path.

Resilience and Maintainability Implications

  • observed — An unverifiable installation self-test throws rather than authorizing fallback. Unconfirmed termination is propagated, and self-test retries stop when teardown is unconfirmed, preventing another attempt from being stacked over potentially active remote work.

Hardening Proposals

  • proposed — Require the target-pinned executable hash when accepting a cached Windows runtime before launch. Treat .verified as publication history, not proof that mutable executable bytes remain unchanged. This closes the deterministic warm-cache gap without claiming to eliminate races against an already-authorized filesystem writer.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.76% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 18 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding a pinned-Node relay for Windows SSH hosts.
Description check ✅ Passed The description covers the main template sections, including the user impact, implementation, rationale, linked issue reference, visual-proof status, testing, and follow-up work. It also clearly discl…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • 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.

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

Important

A Windows application-control refusal is classified as noexec, which makes the first connect for that host terminate at rung D with a POSIX "noexec mount" message even though the remembered retry steps past it to the host-Node fallback.

Reviewed changes

  • D6 ladder integration — the Windows pinned-Node feature is rebased onto #24133: rung A now runs planPinnedNodeRelay for win32 (ssh-relay-runtime-step-plan.ts), and ensurePinnedRelayRuntime / runPinnedRuntimeSelfTest thread RelayRuntimeLadderRun, expectPinnedVersion, and the ladder's remembered flag through to rung A's refusal.
  • win32 gating moved to rung C — rung A no longer throws windows_host_unsupported; only the POSIX-only host-Node addon relay keeps the guard, with updated wording.
  • Remembered-refusal coverage — a new test asserts a Windows security_software refusal is replayed as remembered: true, and the Windows self-test now defaults to requiring the pinned version.

One inline concern below: the new app-control classification interacts badly with the ladder's terminal-noexec rule, and the new security_software refusal is missing from the telemetry enum.

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

Comment on lines +56 to +62
// Windows application control refuses to start binaries under the user profile.
if (
/blocked by group policy|Application Control policy|AppLocker|software restriction/i.test(
output
)
) {
return 'noexec'

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.

Classifying application-control blocks as noexec makes the D6 ladder end the whole connect on the first attempt for that host: nextRelayRuntimeStep(ladder, 'A', 'noexec', remembered=false) returns D (ssh-relay-runtime-ladder.ts:63), and rung D prints the POSIX "home directory is mounted noexec" message. On a later connect the same refusal is remembered, remembered=true skips the terminal jump, and rung A steps to legacy — so the identical host condition fails once and then works. security_software (added in this PR) is non-terminal and would keep the host-Node fallback on both attempts.

Technical details
# Windows application-control refusals should not map to the terminal `noexec` rung

## Affected sites
- `src/main/ssh/ssh-relay-runtime-self-test.ts:56-62` — app-control block (`blocked by group policy|Application Control policy|AppLocker|software restriction`) → `noexec`.
- `src/main/ssh/ssh-relay-runtime-ladder.ts:63` — `noexec && !remembered` → `D`; otherwise the next rung.
- `src/main/ssh/ssh-relay-pinned-node-install.ts:99-103` — the fresh refusal is built with the 2-arg `PinnedRelayFallbackError`, i.e. `remembered=false`.
- `src/main/ssh/ssh-relay-pinned-node.ts:279-289` — a later connect replays the recorded refusal as `remembered=true`.
- `src/main/ssh/ssh-relay-runtime-ladder.ts:80-96` — `noexec` maps to `home_noexec` and suppresses the refusal suffix, so the user sees the mount wording with no diagnostic.
- `src/main/ssh/ssh-relay-runtime-step-plan.ts:81-85` and `src/main/ssh/ssh-relay-host-node-addons.ts:53-58` — rung C is hard-refused on win32, so legacy is the only Windows fallback.

## Required outcome
- A Windows app-control block must fall back to the host-Node relay on the first connect, not fail at rung D, and must not surface the POSIX noexec wording.

## Suggested approach (optional)
- Classify the app-control patterns as `security_software` (non-terminal, already added in this PR), or otherwise make the fresh and remembered paths agree. This needs updating `ssh-relay-pinned-node-install.test.ts:250-257`, which currently pins `reason: 'noexec'`.

## Open questions for the human (optional)
- Is terminal rung D intentional for AppLocker? Rung C is hard-refused on win32 and legacy resolves the host's Program Files Node, so the "noexec defeats every rung" premise does not hold as written for Windows.

'wrong_libc'
'wrong_libc',
// Windows: AV or application control removed, rewrote or blocked verified bytes.
'security_software'

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.

security_software is now a PinnedRuntimeRefusal, but SSH_RUNTIME_REFUSAL_VALUES (src/shared/telemetry-ssh-runtime-event-schemas.ts:59) was not updated, so ssh-remote-runtime-telemetry.ts:88's pick() records it as first_refusal: 'none'. The Windows AV/tampering signal this PR added is dropped from fleet telemetry, and if the rung-A classification is moved to security_software, the whole class would go dark.

@OrcaWin
OrcaWin merged commit 67014c8 into main Oct 1, 2026
52 checks passed
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