Repository navigation
feat(ssh): pinned-Node relay on Windows SSH hosts - #24135
Conversation
|
Comments Outside DiffThese findings could not be posted inline.
|
There was a problem hiding this comment.
ℹ️ No critical issues — one minor cleanup gap inline.
Reviewed changes
- Windows runtime store (
orcad-remote-node-runtime-windows.ts, new) — probe/present/promote as singlepowerShellCommandlines: hash the zip, extractnode.exevia System32tar.exe(Expand-Archive fallback), hash and run it, then publish with one[IO.Directory]::Moveand a.verifiedmarker; verified bytes that change later are reported as security software. - Shared verdict plumbing (
orcad-remote-node-runtime-report.ts, new) — tokens plusassertRemoteNodeRuntimePromoted,RemoteNodeRuntimeSecurityModifiedError, and\r?\n-tolerantparseRemoteRuntimeExitReport;orcad-remote-node-runtime.tsre-exports them. - Host dispatch (
orcad-remote-node-runtime.ts) — Windows branches for probe/present,wrapCommand: falseon Windows, and the upload stage rides the probe to save a spawn;finallyskips the cleanup exec on Windows viahostRemovedStage. - Plan/install (
ssh-relay-pinned-node.ts,ssh-relay-pinned-node-install.ts) — drops thewindows_host_unsupportedrefusal, resolveswin32-*targets, addswindows-process-tree.nodeto the win32 addon list, maps a security-modified host verdict to thesecurity_softwarerefusal, 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 newsecurity_softwarerefusal. - Relay side (
relay-runtime-identity.ts,relay-windows-conpty.ts,pty-handler.ts) — recognizesruntimes\node-<sha>\node.exeaspinned-nodeand opts only a pinned win32 relay into the bundled ConPTY DLL; the self-test looks forconpty.nodeand refuses a quarantined pair. - Template targets (
src/shared/node-runtime-pin.ts) —ORCAD_TEMPLATE_TARGETSnow 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const probe = await exec( | ||
| conn, | ||
| host, | ||
| windows | ||
| ? windowsNodeRuntimeProbeCommand(runtimeDir, target, stageDir) |
There was a problem hiding this comment.
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.876e541 to
b111d20
Compare
536d6b9 to
2eb9ff5
Compare
| // 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) { |
There was a problem hiding this comment.
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.
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).
2eb9ff5 to
481a142
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)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 selected for processing (18)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughWindows 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 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 ReviewSecurity architecture risk: 🟡 Moderate · up to 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
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
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
planPinnedNodeRelayfor win32 (ssh-relay-runtime-step-plan.ts), andensurePinnedRelayRuntime/runPinnedRuntimeSelfTestthreadRelayRuntimeLadderRun,expectPinnedVersion, and the ladder'srememberedflag 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_softwarerefusal is replayed asremembered: 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| // 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' |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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.

ELI5
Windows SSH hosts that opt into "Orca-managed Node" now get the pinned
node.exeplus Orca's prebuilt ConPTY terminal addons, instead of falling back to the host's own Node.What Changed
orcad-remote-node-runtime-windows.ts):runtimes\node-<sha>\node.exewith Get-FileHash, then upload the officialnode-v24.21.0-win-<arch>.zip.tar.exe(Expand-Archiveas a fallback), hashes and runsnode.exe --version, and publishes with a single directory move plus.verified.node.exekeeps its real name.powerShellCommandcall: no new-EncodedCommandsite, no-ExecutionPolicy, noAdd-Type.conpty.node,conpty.dll/OpenConsole.exe, the console-list addon), the watcher andwindows-process-tree, then launches onnode.exe. The self-test opens a PTY with the bundled ConPTY.ORCAD_TEMPLATE_TARGETSnow includes the win32 targets.Why
This is design D5 (Windows). Keeping the official signed
node.exeunder 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.win32handling have unit tests.Fixed in review: a redundant
powershell.exestage cleanup is removed.Not yet run on a real Windows host. Next step: the Windows SSH provider harness (
config/ci/windows-ssh-provideronOrcaWin/np-windows-ssh-provider-diagnostic), on Win32-OpenSSH preview and inbox, x64 and ARM64.Follow-ups:
Add-Typewith a read through the verifiednode.exe.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.