Skip to content

fix(agent-hooks): keep the hook event payload off the curl command line - #4475

Merged
nwparker merged 4 commits into
stablyai:mainfrom
BorjaLL:BorjaLL/agent-hook-payload-fix
Jul 3, 2026
Merged

nwparker merged 4 commits into
stablyai:mainfrom
BorjaLL:BorjaLL/agent-hook-payload-fix

Conversation

@BorjaLL

@BorjaLL BorjaLL commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Keeps the agent-hook event payload off the curl command line. Every managed agent-hook script previously posted the payload as an inline --data-urlencode "payload=${payload}" argument — so tens of KB of tool output landed on the process command line, visible to ps and to EDR/antivirus tools that flag oversized or "suspicious" command lines (false positives that could kill the hook or the agent).

The fix pipes the payload to curl's stdin and reads it back with curl's @- form:

payload=$(cat)
...
printf '%s' "$payload" | curl -sS -X POST ... --data-urlencode "payload@-" ...

--data-urlencode "payload@-" reads the payload field's value from stdin and URL-encodes it exactly as before, so the POST wire body is byte-for-byte identical. Applied uniformly across all managed agent hook scripts (claude, codex, cursor, copilot, gemini, grok, kimi, devin, droid, antigravity, command-code), matching the pattern installer-utils already uses for the Windows curl.exe path.

Evidence

  • Repro (before): payload appears as a --data-urlencode "payload=${payload}" argv element — visible on the command line.
  • After: payload is piped via stdin; no hook script contains the inline payload=${payload} form (asserted by .not.toContain(...) in each hook-service test).
  • Tests: agent-hooks + per-agent hook-service suites pass (362 passed / 5 skipped). pnpm run typecheck clean across node/cli/web; oxlint clean on all touched files.
  • Approach note: the original PR streamed the payload via a temp file; this takeover switched to stdin piping instead, which removes the temp file entirely — no temp-file permissions, cleanup, or symlink-race surface — while achieving the same "payload off the command line" goal.

ELI5

When an agent finishes a step, Orca runs a tiny script that phones home to the app with what happened. That script used to shout the whole message on the command line, where security software could see it, get suspicious about the size, and kill it. Now the script whispers the message through a private pipe instead — same message arrives, but it's no longer sitting out in the open for antivirus to trip over.

Trade-offs

  • No wire-format change: the receiver gets the identical payload form field; command substitution already stripped trailing newlines, and printf '%s' re-emits the same bytes.
  • No temp files (unlike the original approach) → no cleanup/permissions/race concerns; nothing touches the filesystem.
  • POSIX-sh path only; the Windows curl.exe path already used stdin. Works identically over SSH (the change is in the generated script text run on the remote).
  • No dependency, credential-handling, or workflow changes; the hook token stays in an HTTP header, never in the payload or on the command line.

This PR was taken over, rebased on latest main, verified, and reviewed by a maintainer before merge. Original author: @BorjaLL.

…ing it on the curl command line

The POSIX agent-hook script for every curl-based agent inlined the full
event payload via `curl --data-urlencode "payload=${payload}"`. Tool
output can be tens of KB, so the resulting process command line could be
multi-KB — which endpoint security tools (e.g. Microsoft Defender for
Endpoint) flag as an oversized/suspicious command line. That produced a
false-positive detection on Orca's own loopback (127.0.0.1) telemetry POST.

Stream the payload to an mktemp file and post it with
`--data-urlencode "payload@$payload_file"` instead. The urlencoded body on
the wire is byte-identical, so the agent-hook receiver is unchanged; the
payload simply never appears on a process command line. `trap ... EXIT`
removes the temp file on every exit path. Small bounded metadata fields
(paneKey/tabId/worktreeId/env/version) stay inline.

Applied to all curl-based agents: claude, codex, command-code, copilot,
cursor, droid, gemini, grok, antigravity. (amp/hermes/opencode post via
the HTTP request body and were never affected.) The Windows post-command
shares the same latent pattern and is flagged as follow-up.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@AmethystLiang
AmethystLiang requested review from Jinwoo-H and removed request for brennanb2025 June 2, 2026 17:08
@BorjaLL

BorjaLL commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Friendly nudge for review: this one is green (CI passing) and currently the only one of my open PRs that's cleanly mergeable against main. Small diff (+95/-32). Happy to address any feedback. cc @nwparker

…yload-fix

# Conflicts:
#	src/main/antigravity/hook-service.test.ts
#	src/main/cursor/hook-service.test.ts
#	src/main/grok/hook-service.test.ts
@ghost

ghost commented Jun 19, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 5 individual chapters for you:

Title
1 Stream Claude hook payload to temp file
2 Update other agent hooks to use temp files
3 Handle empty stdin in Antigravity hooks
4 Verify hook script changes in tests
5 Apply unrelated linting and formatting fixes
Open in Stage

Chapters generated by Stage for commit 6d96deb on Jun 19, 2026 9:49pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

All POSIX managed hook scripts generated by getManagedScript() across nine AI provider hook services (antigravity, claude, codex, command-code, copilot, cursor, droid, gemini, grok) were updated to stop reading stdin into a shell variable. Instead, each script now creates a temporary file via mktemp, registers an EXIT trap to delete it, writes the incoming payload into that file, exits early when the file is empty, and transmits the payload to the local hook endpoint using curl's --data-urlencode "payload@${payload_file}" syntax. Tests for antigravity, cursor, and grok were updated to assert this new flow and verify the deprecated inline form is absent. Three unrelated runtime files received whitespace-only reformatting with no logic changes.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description has useful context, but it omits required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Restructure the PR description to match the template and add the missing sections, including screenshots status, testing results, AI review, security audit, and notes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: moving hook event payloads off the curl command line to avoid EDR false-positives.
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.

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.

nwparker and others added 2 commits July 3, 2026 14:33
Resolve conflicts with main (command-code moved to command-code-managed-script.ts,
Windows wrapper refactor). Reimplement the payload-off-the-command-line fix as a
stdin pipe (printf '%s' "$payload" | curl --data-urlencode "payload@-") instead
of a temp file: byte-identical wire, no temp file to secure/clean up, and it matches
the codebase's existing Windows curl.exe hook post. Extend to devin and kimi, which
have the same inline-payload exposure.

Co-authored-by: Orca <[email protected]>
@nwparker
nwparker merged commit 4797cf8 into stablyai:main Jul 3, 2026
@nwparker

nwparker commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Merged — this passed our review bar. @BorjaLL thanks for the contribution and the clear EDR-false-positive diagnosis! A maintainer took this over and rebased it on latest main. One change from your original: instead of streaming the payload through a temp file, we switched to piping it to curl's stdin (printf '%s' "$payload" | curl … --data-urlencode "payload@-"). That reaches the same goal — payload off the command line — while removing the temp file entirely (no cleanup/permissions/symlink-race surface), and it matches the stdin pattern installer-utils already uses for the Windows curl.exe path. Wire body is byte-identical. Applied across all managed agent hook scripts; 362 hook tests pass, typecheck + lint clean.

@nwparker

nwparker commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Thank you, @BorjaLL — great catch. Big hook payloads riding on the curl command line and tripping EDR/AV false positives is the kind of thing that's easy to miss until it bites someone. We landed it via stdin piping so there's no temp file to manage and the wire body stays byte-identical to before. Really appreciate you flagging and fixing it — merged!

@nwparker

nwparker commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Thank you, Borja! 🙏 Great catch — tens of KB of payload on the curl command line tripping EDR is the kind of thing you only find if you're actually watching your process list. We landed it via stdin piping (same goal, no temp file). Sharp contribution — thanks for it. 🐋

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ing it on the curl command line (stablyai#4475)

The POSIX agent-hook script for every curl-based agent inlined the full
event payload via `curl --data-urlencode "payload=${payload}"`. Tool
output can be tens of KB, so the resulting process command line could be
multi-KB — which endpoint security tools (e.g. Microsoft Defender for
Endpoint) flag as an oversized/suspicious command line. That produced a
false-positive detection on Orca's own loopback (127.0.0.1) telemetry POST.

Stream the payload to an mktemp file and post it with
`--data-urlencode "payload@$payload_file"` instead. The urlencoded body on
the wire is byte-identical, so the agent-hook receiver is unchanged; the
payload simply never appears on a process command line. `trap ... EXIT`
removes the temp file on every exit path. Small bounded metadata fields
(paneKey/tabId/worktreeId/env/version) stay inline.

Applied to all curl-based agents: claude, codex, command-code, copilot,
cursor, droid, gemini, grok, antigravity. (amp/hermes/opencode post via
the HTTP request body and were never affected.) The Windows post-command
shares the same latent pattern and is flagged as follow-up.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Neil <[email protected]>
Co-authored-by: Orca <[email protected]>
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.

3 participants