Repository navigation
fix(agent-hooks): fail closed without detected agent allowlist - #11676
Conversation
Greptile SummaryThis PR fixes a security hole where an omitted or empty
Confidence Score: 5/5The change is a well-contained fail-closed fix with layered guards and direct regression coverage; safe to merge. The null-means-all-agents hole is closed at two independent layers (runtime and installer), both new guards are exercised by updated or new tests, and the relay layer already normalised missing agents to [] before this PR. All updated tests now pass an explicit allowlist rather than relying on the old implicit default, so the API contract is clearly documented in the test suite. Files Needing Attention: No files require special attention. The runtime short-circuit in managed-hook-runtime.ts is only indirectly exercised through relay tests that mock the function, but the guard is a single-line length check on an already-validated array.
|
| Filename | Overview |
|---|---|
| src/main/agent-hooks/remote-managed-hook-installers.ts | Core fix: replaces null-sentinel install-all pattern with explicit empty-set early return; exports REMOTE_MANAGED_HOOK_INSTALLER_AGENTS for test parity. |
| src/main/agent-hooks/managed-hook-runtime.ts | Adds early-exit guard before home/host probes when agents list is empty; passes resolved agents array through to avoid re-reading options downstream. |
| src/main/agent-hooks/remote-hook-service-installers.test.ts | Adds regression test for omitted/empty allowlist; updates the full-install and abort tests to use the explicit REMOTE_MANAGED_HOOK_INSTALLER_AGENTS constant. |
| src/main/agent-hooks/managed-hook-local-filesystem.test.ts | Updates cold/warm install and corrupt-config tests to pass explicit agents allowlist, aligning with the new fail-closed API contract. |
| src/main/agent-hooks/wsl-hook-relay-manager.test.ts | Updates WSL integration test to pass the explicit agents allowlist constant when exercising a full install against the real WSL guest home. |
Sequence Diagram
sequenceDiagram
participant SSH as ssh-relay-session
participant Relay as managed-hook-installer (relay)
participant Runtime as installManagedHooks (runtime)
participant Installer as installRemoteManagedAgentHooks
SSH->>SSH: detectedManagedHookAgents()
alt "agents.length === 0"
SSH-->>SSH: return (no relay request)
else agents present
SSH->>Relay: "AGENT_HOOK_INSTALL_MANAGED_HOOKS_METHOD {agents}"
Relay->>Relay: readAgents(params) → [] if omitted
Relay->>Runtime: "installManagedHooks({agents})"
alt "agents.length === 0 [NEW guard]"
Runtime-->>Relay: "{installers:0, errors:0}"
else agents present
Runtime->>Runtime: resolveRelayGrokHome / readManagedHookHostIdentity
Runtime->>Installer: "installRemoteManagedAgentHooks(fs, home, {agents})"
alt "allowedAgents.size === 0 [NEW guard]"
Installer-->>Runtime: []
else agents present
loop for each agent in REMOTE_MANAGED_HOOK_INSTALLERS
alt agent in allowedAgents
Installer->>Installer: install(sftp, remoteHome, options)
end
end
Installer-->>Runtime: AgentHookInstallStatus[]
end
Runtime-->>Relay: "{installers, errors}"
end
Relay-->>SSH: "{installers, errors}"
end
Reviews (1): Last reviewed commit: "fix(agent-hooks): fail closed without de..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughManaged hook installation now fails closed when the agent allowlist is omitted or empty. The runtime passes a normalized agent array to remote installation. The remote installer avoids filesystem and configuration mutations without an allowlist. Local filesystem, remote installer, cancellation, and WSL tests now pass the shared managed-agent list explicitly. Tests also verify fail-closed behavior, abort handling, and allowlisted Claude installation. Mergeability Score: ⚪ Minimal · up to The change prevents hook installation when no agents are explicitly allowlisted while preserving intentional full-install paths through explicit configuration; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
|
Taking a look! |
|
Verification — land-as-is (0 blockers), reviewed at Independent code review (two reviewers) + a perf audit + a live SSH-relay reproduction rig all agree the change is correct and strictly narrowing. Live rig — disposable Linux SSH host, isolated
No config write differs on any path — the change only ever narrows installation. On the empty/omitted path it additionally drops a login-shell subprocess (8s timeout ceiling) and a lock Gates at One non-blocking nit (both reviewers): the runtime-level early return in This is a verification note, not an approval or merge — the only remaining item is the maintainer-gated CI workflow run. |
|
@brennanb2025 following up on your note that the only remaining item is the maintainer-gated CI workflow: could you hit "Approve and run workflows" on the PR Checks run for dc758247e0? The head is unchanged since your verification — deliberately so. |
|
Electron + live-SSH validation — closes the one gap left open in my earlier verification. Still land-as-is at My previous comment noted the Electron app-level check was unverified (the isolated dev profile had wedged during Setup: Orca dev build launched from the PR head (identity verified over CDP: Negative case — no agent CLI installed on the remote (this is #11641). Run in Orca's own remote terminal on the SSH host: Zero of the 14 agent config homes were created. Positive case — exactly one agent detected. With only
Revert-proofing: reverting only the leaf guard turns the new test red with Gates at this head: 41/41 tests in the touched files, I also re-traced the call sites to check the one regression that would matter — hooks that used to install and now silently don't. All three production callers (SSH, WSL, and the relay handler) already detect agents and pass an explicit allowlist, returning early on zero, so no live path changes behavior. The two side effects the runtime early-return now skips (the install lock and the Grok-home resolution) each have exactly one caller, this function, so nothing else depends on them. Thanks for the clean, minimal fix and for holding the head steady — that made verification straightforward. |
|
@brennanb2025 thank you for closing the Electron + live-SSH gap — the negative (0/14 homes) and single-agent positive cases are exactly the #11641 contract. Holding the head at |
|
Thanks for this — it's a real hole, and the fix is the standard shape for it (coerce the missing allowlist to an empty set and filter), so I kept your approach as-is. Heads up that I pushed one commit to your branch: Your new regression test already pins the leaf guard, but the early return you added to For what it's worth, that skip is also a decent win on its own: the empty-allowlist path went from ~290 ms and a One thing we're tracking separately, not a blocker here — when remote agent detection is unavailable, the remote path returns |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/main/agent-hooks/managed-hook-runtime.test.ts (2)
8-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the platform temporary directory.
Line 8 hardcodes
/tmpfor every non-Windows run. Usetmpdir()for all platforms. This avoids assuming a specific POSIX temporary root.As per coding guidelines, use Node path utilities for file paths and do not assume
/or\.Proposed fix
-const tempRoot = process.platform === 'win32' ? tmpdir() : '/tmp' +const tempRoot = tmpdir()Source: Coding guidelines
52-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRun the fail-closed regression on Windows.
Line 52 skips the complete suite on Windows. The omitted and empty allowlist paths return before
resolveRelayGrokHome, so those cases do not require the POSIX shell fixture. Run these cases outside the platform-gated suite, or add a Windows-compatible variant.Based on the supplied runtime contract, the empty-list return occurs before home and host probes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 114fec8a-714e-4649-aef5-f3244a3a82b1
📥 Commits
Reviewing files that changed from the base of the PR and between dc758247e07d15ab7b3393782b0903d4b87b1f3d and 8f3668ca729afbfec6c9f9d320a9910fd931ba9e.
📒 Files selected for processing (1)
src/main/agent-hooks/managed-hook-runtime.test.ts
|
@brennanb2025 thanks for keeping the approach and for the Noted on the remote |
Omit/empty agents no longer means install every remote managed hook. Closes the remaining hole after stablyai#11442 that recreated uninstalled agent config homes via the relay/SSH/WSL install path (stablyai#11641).
The leaf guard already had a regression test, but the early return in installManagedHooks was invisible to the suite: reverting it left every agent-hooks and relay test green, because the leaf guard makes the summary identical and the only delta is side effects (GROK_HOME login-shell probe, host-identity read, ~/.orca mkdir + install lock).
8f3668c to
40cec3b
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Merged latest The only collision was One wrinkle worth flagging: your install tests observe the probe through the real login-shell run log, and main's mock is a bare No source logic changed — Thanks for the fix! 🙏 |
|
Apologies for the slow turnaround here 🙏 CI is running now and I'll merge once it's green. Thanks for this — failing closed on the allowlist is the right default, and it matches how comparable tools gate this. We're picking up the rest of #11641 as a follow-up: making writes into agent config files we don't own fully non-destructive, and not creating config homes for agents that aren't installed. This PR is the right foundation for that. Appreciate your patience! |
…yai#11676) * fix(agent-hooks): fail closed without detected agent allowlist Omit/empty agents no longer means install every remote managed hook. Closes the remaining hole after stablyai#11442 that recreated uninstalled agent config homes via the relay/SSH/WSL install path (stablyai#11641). * test(agent-hooks): pin installManagedHooks fail-closed gate The leaf guard already had a regression test, but the early return in installManagedHooks was invisible to the suite: reverting it left every agent-hooks and relay test green, because the leaf guard makes the summary identical and the only delta is side effects (GROK_HOME login-shell probe, host-identity read, ~/.orca mkdir + install lock). --------- Co-authored-by: Brennan Benson <[email protected]>
Summary
installRemoteManagedAgentHookswhen the detected-agent allowlist is omitted or empty (previouslyundefinedmeant install every agent).installManagedHooksbefore host/home probes when no agents are allowlisted.This hardens the remaining hole after #11442 so a relay/SSH/WSL install path cannot recreate config homes for uninstalled agents.
Closes #11641
Test plan
vitest runfocused suites:remote-hook-service-installers.test.tsmanaged-hook-local-filesystem.test.tsmanaged-agent-hook-controls.test.tsmanaged-hook-installer.test.ts(relay)