Repository navigation
fix(agent-hooks): stop the Windows hook launcher spelling the AV-denied flag pair (STA-5237) - #16739
Conversation
📝 WalkthroughWalkthroughThe Windows PowerShell hook launcher now uses 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The change addresses Resolution Update the linked issue requirements to explicitly supersede the hidden-window requirement, or provide an implementation that avoids the AV trigger while preserving hidden execution. Complete the required Windows window-behavior measurements before merging if Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 10 files. (1 skipped: 1 unsupported.) Full details: Description checkExplanation The description is detailed and on-topic. It explains the failure, changed command line, rationale, scope, linked issue, compatibility impact, measurements, tests, and unexecuted Windows-only suites. It does not use all template headings or complete the checklist, but the required information is mostly present.
✨ 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.
🧹 Nitpick comments (1)
src/main/agent-hooks/windows-powershell-hook-launcher.ts (1)
17-41: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCondense the duplicated incident history. Keep the current launcher invariant and issue references, but remove the detailed chronology and host measurements.
src/main/agent-hooks/windows-powershell-hook-launcher.ts#L17-L41: state that-WindowStyle Hiddenmust remain absent with-EncodedCommand, then link the relevant issues.src/main/agent-hooks/windows-powershell-hook-launcher.test.ts#L15-L28: keep only the test-specific reason for pinning the command shape, or refer to the launcher comment.As per coding guidelines: “BE CONCISE. 1 LINE if possible.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 81a89ba8-b9a9-4f46-83f8-f26e825c3e86
📒 Files selected for processing (11)
.github/workflows/pr.ymlsrc/main/agent-hooks/installer-utils.test.tssrc/main/agent-hooks/windows-powershell-hook-launcher.test.tssrc/main/agent-hooks/windows-powershell-hook-launcher.tssrc/main/claude/hook-service.test.tssrc/main/codex/hook-service-managed-install.test.tssrc/main/command-code/hook-service.test.tssrc/main/cursor/hook-service.test.tssrc/main/droid/hook-service.test.tssrc/main/gemini/hook-service.test.tssrc/main/grok/hook-service.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
b68b883 to
3e68309
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/agent-hooks/windows-powershell-hook-launcher.test.ts (1)
16-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten this TypeScript comment. Keep only the launcher invariant and the live-measurement gap; move issue history and host measurements to PR documentation. No functional change is required.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 85e15f69-0a5f-4328-a647-d144407113e8
📒 Files selected for processing (4)
.github/workflows/pr.ymlsrc/main/agent-hooks/installer-utils.test.tssrc/main/agent-hooks/windows-powershell-hook-launcher.test.tssrc/main/cursor/hook-service.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Review status: clean within scopeReviewed and pushed head Windows Electron A/B gateValidated the exact reviewed head in an isolated Orca Electron dev instance on Windows 11 high spec using Playwright CDP. Each arm reset its window sampler and required a non-zero hook fire before window counts were accepted.
Temporary WITH-flag hook settings were restored afterward and the Windows PR worktree remained clean. Verification
Remaining CI stateThe required A direct run of No in-scope blocker remains; merge is mechanically blocked until the unrelated required-check baseline is resolved or rerun on a fixed base. |
…ed flag pair (STA-5237) `-WindowStyle Hidden` + `-EncodedCommand` is denied at CreateProcess by Kaspersky on Windows 11, whatever the payload decodes to. Bash reports it as `Permission denied` and every managed hook event fails, so agent status never arrives; the parent shell also briefly cannot spawn anything afterwards, so a denied hook can take the user's next command down with it. Measured on the reporting host (#16003), with a harmless `exit 0` payload: -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand 126 -NoProfile -WindowStyle Hidden -EncodedCommand 126 -WindowStyle Hidden -EncodedCommand 126 -NoProfile -EncodedCommand 0 (5/5) #16576 removed `-ExecutionPolicy Bypass`, which is the one flag of the three NOT in the signature, so hooks kept failing after that fix. The pair that has to stop being spelled is `-WindowStyle Hidden` + `-EncodedCommand`. Because the change is to the shared switch constant, it covers every site that spells the denied pair in one edit: Claude via `wrapWindowsPowerShellEncodedCommand`, gemini/cursor/droid/command-code/copilot via `wrapWindowsHookCommand`, the `runtime-home-hook-command` unsafe-HOME fallback, and the spaced-path fallback for codex/grok/devin/antigravity. Only a flag is removed, so parser and payload compatibility is unchanged for every executor: the string is still a PowerShell command line, still one self-contained token, still base64-shielded. The tradeoff, recorded rather than hidden: `-WindowStyle Hidden` was the shipped fix for #14815 (+#14828, #15117, #15447, #15767), and this removes it. Its suppression was never measured — #14825 confirmed it visually, #16576's author stated it "remains unverified on a real box", and #15506's author argued it cannot help a `.cmd` child with no console to inherit. The console is allocated by the parent chain, not by this command line. A live window measurement is still outstanding and is called out in the PR. Also adds `windows-hook-payload-delivery.test.ts` to the PR CI Windows leg, which had never run it.
3e68309 to
1efd27d
Compare
…ed flag pair (STA-5237) (stablyai#16739) * fix(agent-hooks): stop the Windows hook launcher spelling the AV-denied flag pair (STA-5237) `-WindowStyle Hidden` + `-EncodedCommand` is denied at CreateProcess by Kaspersky on Windows 11, whatever the payload decodes to. Bash reports it as `Permission denied` and every managed hook event fails, so agent status never arrives; the parent shell also briefly cannot spawn anything afterwards, so a denied hook can take the user's next command down with it. Measured on the reporting host (stablyai#16003), with a harmless `exit 0` payload: -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand 126 -NoProfile -WindowStyle Hidden -EncodedCommand 126 -WindowStyle Hidden -EncodedCommand 126 -NoProfile -EncodedCommand 0 (5/5) NOT in the signature, so hooks kept failing after that fix. The pair that has to stop being spelled is `-WindowStyle Hidden` + `-EncodedCommand`. Because the change is to the shared switch constant, it covers every site that spells the denied pair in one edit: Claude via `wrapWindowsPowerShellEncodedCommand`, gemini/cursor/droid/command-code/copilot via `wrapWindowsHookCommand`, the `runtime-home-hook-command` unsafe-HOME fallback, and the spaced-path fallback for codex/grok/devin/antigravity. Only a flag is removed, so parser and payload compatibility is unchanged for every executor: the string is still a PowerShell command line, still one self-contained token, still base64-shielded. The tradeoff, recorded rather than hidden: `-WindowStyle Hidden` was the shipped fix for stablyai#14815 (+stablyai#14828, stablyai#15117, stablyai#15447, stablyai#15767), and this removes it. Its suppression was never measured — stablyai#14825 confirmed it visually, stablyai#16576's author stated it "remains unverified on a real box", and stablyai#15506's author argued it cannot help a `.cmd` child with no console to inherit. The console is allocated by the parent chain, not by this command line. A live window measurement is still outstanding and is called out in the PR. Also adds `windows-hook-payload-delivery.test.ts` to the PR CI Windows leg, which had never run it. * test(agent-hooks): keep launcher token out of source grep (cherry picked from commit 928d306)
…ed flag pair (STA-5237) (stablyai#16739) * fix(agent-hooks): stop the Windows hook launcher spelling the AV-denied flag pair (STA-5237) `-WindowStyle Hidden` + `-EncodedCommand` is denied at CreateProcess by Kaspersky on Windows 11, whatever the payload decodes to. Bash reports it as `Permission denied` and every managed hook event fails, so agent status never arrives; the parent shell also briefly cannot spawn anything afterwards, so a denied hook can take the user's next command down with it. Measured on the reporting host (stablyai#16003), with a harmless `exit 0` payload: -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand 126 -NoProfile -WindowStyle Hidden -EncodedCommand 126 -WindowStyle Hidden -EncodedCommand 126 -NoProfile -EncodedCommand 0 (5/5) stablyai#16576 removed `-ExecutionPolicy Bypass`, which is the one flag of the three NOT in the signature, so hooks kept failing after that fix. The pair that has to stop being spelled is `-WindowStyle Hidden` + `-EncodedCommand`. Because the change is to the shared switch constant, it covers every site that spells the denied pair in one edit: Claude via `wrapWindowsPowerShellEncodedCommand`, gemini/cursor/droid/command-code/copilot via `wrapWindowsHookCommand`, the `runtime-home-hook-command` unsafe-HOME fallback, and the spaced-path fallback for codex/grok/devin/antigravity. Only a flag is removed, so parser and payload compatibility is unchanged for every executor: the string is still a PowerShell command line, still one self-contained token, still base64-shielded. The tradeoff, recorded rather than hidden: `-WindowStyle Hidden` was the shipped fix for stablyai#14815 (+stablyai#14828, stablyai#15117, stablyai#15447, stablyai#15767), and this removes it. Its suppression was never measured — stablyai#14825 confirmed it visually, stablyai#16576's author stated it "remains unverified on a real box", and stablyai#15506's author argued it cannot help a `.cmd` child with no console to inherit. The console is allocated by the parent chain, not by this command line. A live window measurement is still outstanding and is called out in the PR. Also adds `windows-hook-payload-delivery.test.ts` to the PR CI Windows leg, which had never run it. * test(agent-hooks): keep launcher token out of source grep


Summary
-WindowStyle Hidden+-EncodedCommandis denied at CreateProcess by Kaspersky on Windows 11, whatever the payload decodes to —exit 0is denied too. Bash surfaces it asPermission denied(exit 126), so every managed hook event fails and agent status never arrives. Worse, right after a denied call the parent bash briefly cannot spawn anything (dofork: child -1 … errno 13), so a denied hook can take the user's next command down with it.This removes
-WindowStyle Hiddenfrom the shared launcher switch constant. The command line becomespowershell.exe -NoProfile -EncodedCommand <b64>.Fixes #16003. Reported again via user feedback as STA-5237.
Why this flag, and why #16576 did not fix it
Measured on the reporting host with a harmless
exit 0payload:-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -EncodedCommand-NoProfile -WindowStyle Hidden -EncodedCommand(the post-#16576 shape)-WindowStyle Hidden -EncodedCommand-NoProfile -EncodedCommand-NoProfile -ExecutionPolicy Bypass -Command#16576 removed
-ExecutionPolicy Bypass— the one flag of the three not in the signature — so hooks kept failing after it landed. That was reported on #16003 after it was closed. The pair that has to stop being spelled is-WindowStyle Hidden+-EncodedCommand.Reproducible without Orca or any agent CLI, in Git Bash:
This is a regression, not a long-standing condition. The PowerShell launcher shipped in v1.4.187 (2026-08-21) via #14825, replacing
conhost --headless cmd /d /c.git merge-base --is-ancestor 02ba70a847 v1.4.186is false; v1.4.187 is true. The reporter is on v1.4.188, cut 2026-08-22.Scope
Because the change is to the shared constant, it covers every site spelling the denied pair in one edit — Claude via
wrapWindowsPowerShellEncodedCommand(hook-settings.ts:176), gemini/cursor/droid/command-code/copilot viawrapWindowsHookCommand, theruntime-home-hook-command.ts:28unsafe-HOMEfallback, and the spaced-path fallback for codex/grok/devin/antigravity. No agent is left behind, and there is no follow-up needed for the others. (Kimi is unaffected: it ships a Git Bash.shand never emits PowerShell.)Only a flag is removed, so parser and payload compatibility is unchanged for every executor that reads
~/.claude/settings.json— Git Bash, PowerShell (Claude Code's documented fallback when Git Bash is absent), and the command-line/argv[0] spawn used by cursor-agent, Devin, and Grok's Claude-compat import. The string is still a PowerShell command line, still one self-containedcommandwith noargs, still base64-shielded.The tradeoff, stated plainly
-WindowStyle Hiddenwas the shipped fix for #14815 (+ #14828, #15117, #15447, #15767) and this removes it. What the record shows about that flag:.cmdchild that has no console to inherit.CREATE_NO_WINDOWvsDETACHED_PROCESSdiscriminator mattered for Grok in fix(grok): stop the Windows status hook from spawning two interpreters per event #15595.-EncodedCommandsites carry no hidden-window flag and are flagged anyway: the worktree setup runner ([Bug][Windows]: Worktree setup PowerShell wrapper triggers AhnLab V3 MDP detection and is terminated #14233, AhnLab V3) and the OSC 133 bootstrap ([Bug]: [AV False Positive] PowerShell OSC 133 integration triggers 'PowerShell/Bypass.K' EDR flag #16629, enterprise EDR). Those remain open and unowned; this PR does not widen to them.A console flicker is a worse outcome than no flicker — but a far better one than every hook failing plus the parent shell being unable to spawn the user's next command.
Window gate: MEASURED, and it clears
The open question was whether removing
-WindowStyle Hiddenlets a console appear per hook event.It was measured on Windows 11 build 26200 — the same build as the #16003 reporters — in an
isolated Orca Electron instance, with each arm resetting its sampler and requiring a non-zero hook
fire before any window count was accepted (a zero-window reading from a hook that never ran is
indistinguishable from success):
ConsoleWindowClassHWNDsNo console appears either way. That is consistent with #15506's argument that the flag could not
have been suppressing the console for the
.cmdchild, and with #16576's author stating thesuppression was never verified on a real box.
Two limits stated rather than glossed:
command line, so the result is evidence for this configuration, not a universal claim.
Cursor TUI was blocked on login. Fire proof is a listener POST delta of 2 on both arms, so the
command demonstrably ran; but the parent chain was not Cursor's own.
An anti-restoration mutation check confirms the guard works: restoring
-WindowStyle Hiddenmakesthe launcher test fail.
Tests
windows-powershell-hook-launcher.test.ts— asserts the command line spells neither-ExecutionPolicynor-WindowStyle, and pins the exact shape. This is an anti-restoration guard, not proof of the fix: fix(agent-hooks): stop the Windows hook launcher spelling the AV-denied flag triple #16576 round 3 dropped-WindowStyle Hiddenby accident and updated the tests to match, so nothing caught it.grep -rn "WindowStyle" src/ --include='*.ts'must return hits only in the launcher source itself.managed-hook-timeout.test.tsdeliberately not touched — its carrier predicate keys on-EncodedCommand, which does not change.windows-hook-payload-delivery.test.tsto the PR CI Windows leg, which had never run it.Windows-only live suites (
windows-hook-payload-delivery,managed-hook-stdin-lifecycle) were not executed — this machine is macOS.