Repository navigation
Description
Observed in .claude/plugins/data/plugin-quality-melodic-software/evidence/c7ff503b-19e2-40d2-b99e-38c747f7fc0f/guardrails-hooks/20260919T205610Z/audit-notes.md, finding F2 (auditor severity: HIGH). Probe results are direct runs of the registered chain at guardrails 0.35.0. Tier: measured this session (E1).
The guard blocks "Bash file-write workarounds that circumvent Write/Edit hook gates" (the userConfig description in plugin.json). Moving the identical text one level into a -c operand makes it invisible:
| command | exit |
|---|---|
echo secret > a.txt |
2 (blocked) |
printf "%s" x > a.txt |
2 |
cat > a.txt <<EOF ... |
2 |
bash -c 'echo secret > a.txt' |
0 |
sh -c 'echo secret > a.txt' |
0 |
bash -c 'cat > a.txt <<EOF ...' |
0 |
bash -c 'git reset --hard' |
2 (a sibling guard DOES see through) |
The asymmetry is internal to one hook process. grep -n "shell_c_operand" over hooks/*.sh and lib/powershell/*.sh finds call sites in block-convention-violation.sh:431, block-dangerous-git.sh:714, block-no-verify.sh:191 and block-noncanonical-commit.sh:618, and none in block-hook-bypass.sh, block-windows-drive-tmp.sh or block-exported-msys-pathconv.sh.
Why it matters beyond the write gate: secret-pattern-detection is registered only on the Write|Edit|MultiEdit|NotebookEdit and GitHub-MCP matchers in hooks.json, never on Bash|PowerShell. The write gate is what forces content through the lane where the secret scan lives, so bash -c 'echo <credential> > .env' skips both the write gate and the secret scan in one move.
Disclosure gap: the README residual at L136-L139 covers the script-file case ("it does not read the contents of a script that command invokes"). The inline -c case is materially different, since the text is already in .tool_input.command and four sibling guards parse it, and it is named nowhere.
Cheapest fix: add the same hook::shell_c_operand plus hook::bash_parse_segments re-parse that block-dangerous-git.sh:714-715 already uses. This reuses an existing helper and follows the pattern of four sibling guards. Fuller fix: apply it to block-windows-drive-tmp.sh and block-exported-msys-pathconv.sh, which share the gap. If deferred, disclose the -c operand case in both the README residual list and the runtime scope line the guard prints on a block.
Verification: the three bash -c / sh -c rows above must exit 2, with bash -c 'git status' still at 0.
🤖 Generated with Claude Code
Activity
fix(guardrails): block-hook-bypass re-parses sh -c / bash -c operand (#…
docs(guardrails): correct released changelog entries in place