Repository navigation
Description
Severity: SUGGESTION (enforcement-scope disclosure, not a bypass vulnerability).
Component: guardrails plugin, hooks/block-hook-bypass.sh (observed at 0.13.0).
Summary
The guard's user-facing block message asserts an enforcement guarantee that the hook is documented not
to provide. The hook is deliberately producer-scoped and its own header comments name the escape
explicitly — but the message a user sees says nothing about that scope, so it reads as "shell file
writes are blocked" when the accurate statement is "shell file writes in this tool call's command
string are blocked".
What was observed
Two inline Bash commands were blocked during a long fleet-hygiene session:
BLOCKED: cat > file write bypasses Write/Edit hooks
Use the Write or Edit tool instead of a shell file-write workaround.
BLOCKED: echo/printf > file write bypasses Write/Edit hooks
Use the Write or Edit tool instead of a shell file-write workaround.
The identical redirects, placed inside a .sh file and run as bash script.sh, were not blocked — and
this was not incidental: four scripts written that session (execute.sh, wtstate.sh,
remove-clean-worktrees.sh, verify.sh) all append to log files with printf >> and ran freely.
This is by design, and the hook says so
Worth stating plainly so nobody treats this as a hole to plug. The hook's header comments document the
producer-scoped design and name this exact case:
The echo/printf redirect is PRODUCER-SCOPED (see
producer_redirect_bypass): it fires only when the
echo/printf is itself the command whose stdout is redirected into a real file, NOT when anecho
token and a>token merely co-occur in one compound command (bash x.sh > out.json && echo done—
the redirect's producer isbash) …
The hook scans .tool_input.command. It does not — and reasonably cannot — read the contents of a
script that command invokes. That is a sound boundary for a PreToolUse hook.
The actual defect
The message does not carry the scope the design has. "Use the Write or Edit tool instead of a
shell file-write workaround" tells a user their write was prevented and that the sanctioned path is
Write/Edit. It does not say that the guard covers direct redirects in the command string only, so a
reader over-trusts it in both directions:
- An agent concludes shell file writes are unavailable and contorts around a restriction that a script
file does not have — I hit this and rewrote work to route through Write/Edit unnecessarily. - A human reading the block assumes hook coverage the guard never claimed, which is the more expensive
error if the guard is load-bearing in anyone's threat model.
Per the recurring-concerns checklist this is an enforcement scope/tier disclosure gap: the guard is a
speed bump against a specific accidental pattern, and its message is worded like a boundary.
Suggested fix
One line in the block message naming the scope, e.g.:
BLOCKED: echo/printf > file write bypasses Write/Edit hooks
Use the Write or Edit tool instead of a shell file-write workaround.
Scope: direct redirects in this command only — writes inside an invoked script are not inspected.
Alternatively, state the scope wherever the guard's guarantees are documented for consumers, and have
the message point there. No hook logic change is implied.
Environment
guardrails0.13.0 (also present: 0.10.0, 0.12.3), marketplace installmelodic-software- Claude Code on Windows 11 Pro 10.0.26200, Bash tool (Git Bash)
- Surfaced incidentally during a
repo-fleet-hygieneaudit session; filed separately because it is a
different plugin - Observed 2026-07-29/30
Activity
kyle-sexton commentedon Jul 30, 2026
Verified — and the suggested wording would have overstated coverage in the other direction
Reproduced against the hook with fixture PreToolUse JSON (never by live-triggering it):
printf 'x' > out.logbash execute.sh./verify.shpython3 build.pySo the reported behaviour holds: a direct producer redirect blocks, while the identical redirect inside an invoked script is not inspected. The design read is right too — the hook scans
.tool_input.commandand reasonably cannot read a script's contents.One correction, and it changes the fix
The suggested line is:
That would claim more coverage than the guard has. Three more shapes, all direct redirects in the command string, are allowed by the producer-scoped design:
bash execute.sh >> run.logsort data.txt > out.txtcurl https://example.com > page.htmljq . in.json > out.jsonecho hi | tee out.txtcat a.txt b.txt > c.txtThe last one is worth calling out: only the stdin-consuming
cat > fform is a write workaround.catwith input files is ordinary data processing and is allowed, which is correct — but it means "direct redirects in this command" is not the boundary either.The real scope is narrower than either statement: one command string, and only the specific content-producer write forms —
cat > fconsuming stdin,echo/printf > f, inlinepython3 -cwrites, and the PowerShell write cmdlets.Fix
PR incoming.
block_bypass()gains a third line, so every lane carries it:Taking the issue's alternative suggestion as well rather than instead: the
READMEresiduals section — which already documents this guard's quoted-span residual — now states the same scope, so the limit is where consumers read the guard's guarantees and not only at the moment of a block.No hook logic changes. The behaviour the note describes is pinned by tests beside the message-content assertions, so a future change to what the guard blocks cannot silently make its message wrong again. Suite: 210 assertions, 0 failures.
fix(guardrails): state block-hook-bypass's enforcement scope in its b…
docs(guardrails): name tee and other interpreter gaps in block-hook-b…