You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
block-hook-bypass: false-fires when a Bash command contains both an echo token and a redirect (script-stdout capture, or quoted-string arguments) rather than an actual file-authoring bypass #546
BLOCKED: echo > file write bypasses Write/Edit hooks
Use the Write or Edit tool instead of Bash file-write workarounds.
None of the blocked commands authored file content via the shell. They redirected a script's stdout to a scratchpad JSON data file, and separately contained one or more echo status lines elsewhere in the same compound command. Paraphrased examples:
bash fetch-all-pr-comments.sh 526 > pr526.json combined with a trailing echo "EXIT: $?" in the same call.
A bounded poll loop: bash fetch-....sh 526 > poll.json inside a loop body that also had echo "..." summary lines.
The gh issue create for THIS very report — blocked purely because the issue body text contained the literal tokens echo and > describing the bug. Had to fall back to --body-file.
Removing the echo statements (leaving only the redirect capturing script stdout) let the identical redirect through — confirming the trigger is the co-occurrence of an echo token and a > token in one Bash command string, not an actual file-authoring bypass.
Root cause (hypothesis)
The guard heuristic matches echo + > anywhere in the same Bash command string and conflates it with the echo "content" > file content-authoring bypass it is meant to catch. It does not distinguish:
echo "content" > file — the intended target (authoring file content, bypassing Write/Edit), from
some_command > file.json accompanied by an unrelated echo "status" — legitimate (redirecting a subprocess's stdout to a data sink), or
an echo/> appearing only inside a quoted string argument (e.g. a gh issue create --body payload).
Impact
"Run a script, capture its stdout to a scratchpad data file" is blocked whenever an echo appears in the same call, forcing awkward command splitting.
Any command whose string arguments merely mentionecho/> (issue bodies, commit messages, docs about shell) trips the guard — a content-independent false positive.
Suggested fix direction
Scope the match to the concrete echo .../printf ...producer being redirected into a file (i.e. the redirect's left side is the echo/printf), rather than flagging any command string that contains both tokens. Ignore tokens that fall inside quoted argument strings. A subprocess whose stdout is redirected to a data file, and a quoted argument that happens to contain the words, should not trip the guard.
Category
bug (hook false-positive / over-broad heuristic)
Filed as a babysit self-observation. Not refiling the sibling flag-commit-pr-skill-bypass advisory false-fire (already tracked in #545).
This was generated by AI during triage. · Category: bug · Priority:priority: high (guardrails over-broad match blocks legitimate script-stdout capture AND any command whose string args merely mention echo/> — including issue/commit bodies about shell). Routed status: ready.
Plan
block-hook-bypass.sh (PreToolUse:Bash) matches echo + >anywhere in the command string and conflates it with the echo "content" > file content-authoring bypass it targets. It wrongly blocks:
some_command > file.json accompanied by an unrelated echo "status" in the same compound call (redirecting a subprocess's stdout to a data sink — legitimate);
echo/> appearing only inside a quoted argument (e.g. a gh issue create --body "…echo…>…" payload — which blocked the filing of the report itself).
Fix direction: scope the match to the concrete echo … / printf …producer being redirected into a file — i.e. the redirect's left-hand side IS the echo/printf. Ignore echo/> tokens that fall inside quoted argument strings. A subprocess whose stdout is redirected to a data file, and a quoted argument that merely contains the words, must not trip the guard.
Acceptance
bash script.sh > out.json; echo "done" → allowed (redirect producer is the script, not echo).
gh issue create --body "text mentioning echo and >" → allowed (tokens inside a quoted arg).
This lane preemptively routed ALL its GitHub writes through --body-file / -f body=@file (never inline --body), specifically because inline bodies containing shell tokens trip this guard — corroborating the quoted-argument false-positive (case 3). Genuine cat >/printf > file heredoc writes were correctly blocked (true positives), so the fix must preserve those.
Decision defaulted: match only an echo/printf producer on the left of a file redirect, ignoring tokens inside quoted args, rather than any co-occurrence of echo and > — veto before merge
Adjacent facet observed during PR #528 babysitting (round 2): block-hook-bypass also fires on genuineecho >file writes made inside the session scratchpad/temp dir (e.g. $TMPDIR/claude/.../scratchpad) when a verification worker builds a throwaway git sandbox to empirically reproduce shell-logic findings. There the detection is a true positive but the protection is unwanted — the files are disposable and outside any repo. Consider scoping the hook to repo-tracked paths (or exempting the CLAUDE temp/scratchpad root) so sandbox setup does not require git commit --allow-empty / Write-tool workarounds. Filing here rather than as a new issue since it is the same hook; flag if you would prefer it split out.
Both are plain script-stdout capture, no echo/printf producer of file content — matches the issue title's second clause. No action needed beyond this confirming telemetry; #568 already carries the fix.
Activity
kyle-sexton commentedon Jul 19, 2026
This was generated by AI during triage. · Category: bug · Priority:
priority: high(guardrails over-broad match blocks legitimate script-stdout capture AND any command whose string args merely mentionecho/>— including issue/commit bodies about shell). Routedstatus: ready.Plan
block-hook-bypass.sh(PreToolUse:Bash) matchesecho+>anywhere in the command string and conflates it with theecho "content" > filecontent-authoring bypass it targets. It wrongly blocks:some_command > file.jsonaccompanied by an unrelatedecho "status"in the same compound call (redirecting a subprocess's stdout to a data sink — legitimate);echo/>appearing only inside a quoted argument (e.g. agh issue create --body "…echo…>…"payload — which blocked the filing of the report itself).Fix direction: scope the match to the concrete
echo …/printf …producer being redirected into a file — i.e. the redirect's left-hand side IS the echo/printf. Ignoreecho/>tokens that fall inside quoted argument strings. A subprocess whose stdout is redirected to a data file, and a quoted argument that merely contains the words, must not trip the guard.Acceptance
bash script.sh > out.json; echo "done"→ allowed (redirect producer is the script, not echo).gh issue create --body "text mentioning echo and >"→ allowed (tokens inside a quoted arg).echo "content" > file/printf '%s' … > file→ still BLOCKED (genuine content-authoring bypass — the true positive stays caught).Triage corroboration (this lane)
This lane preemptively routed ALL its GitHub writes through
--body-file/-f body=@file(never inline--body), specifically because inline bodies containing shell tokens trip this guard — corroborating the quoted-argument false-positive (case 3). Genuinecat >/printf > fileheredoc writes were correctly blocked (true positives), so the fix must preserve those.Decision defaulted: match only an
echo/printfproducer on the left of a file redirect, ignoring tokens inside quoted args, rather than any co-occurrence ofechoand>— veto before mergekyle-sexton commentedon Jul 19, 2026
Adjacent facet observed during PR #528 babysitting (round 2):
block-hook-bypassalso fires on genuineecho >filewrites made inside the session scratchpad/temp dir (e.g.$TMPDIR/claude/.../scratchpad) when a verification worker builds a throwaway git sandbox to empirically reproduce shell-logic findings. There the detection is a true positive but the protection is unwanted — the files are disposable and outside any repo. Consider scoping the hook to repo-tracked paths (or exempting the CLAUDE temp/scratchpad root) so sandbox setup does not requiregit commit --allow-empty/ Write-tool workarounds. Filing here rather than as a new issue since it is the same hook; flag if you would prefer it split out.fix(guardrails): drop issue tracker ref from test comment
kyle-sexton commentedon Jul 20, 2026
Two more confirming examples from a babysit-prs loop session (2026-07-20, lane: babysit):
python pr_queue_snapshot.py ... > snapshot-latest-run.json 2>&1(redirecting the JSON-producing script's own stdout to a file for orchestrator capture) — false-fired:BLOCKED: echo > file write bypasses Write/Edit hooks.fetch-all-pr-comments.shstdout to a file; worked around by piping topythoninstead of redirecting to a file.Both are plain script-stdout capture, no echo/printf producer of file content — matches the issue title's second clause. No action needed beyond this confirming telemetry; #568 already carries the fix.
fix(guardrails): close comment, leading-redirect, and coproc producer…
fix(work-items): paginate open-linked-PR filter to catch an OPEN clos…
fix(guardrails): detect quoted redirect operands in producer scan