Skip to content

fix(guardrails): treat the heredoc body of git commit -F - and git tag -F - as data in block-root-delete-target - #10047

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-7379-40208797818-1
Oct 25, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-7379-40208797818-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #7379

Summary

Opened by the work-resolve-issue lane. The run's own summary:

block-root-delete-target's rdt_hd_reader now treats a quoted heredoc body as data when the one-line command is git commit or git tag with -F -, so a commit or tag message that names a root delete target is no longer refused. A git global option before the subcommand, any other git subcommand or alias, --file=-, a pipe, a redirect and an opener on a later line are still scanned. After review, the match also refuses a -F - that follows -- or sits in a prefix holding a quote or backslash, because git would read those words as paths. Hold: a human merges this. Human merger: please confirm that the two new stay-quiet cases (git commit -F - and git tag -F -) fail on the base commit b941a9c, as the hook-precision rule requires. This run could not execute the test suite.

Not verified

  • Did not run plugins/guardrails/hooks/block-root-delete-target.test.sh: this lane's Bash runs only the named wrappers. The issue names it as a PR CI check, so it is left to the PR's CI. The expected exit codes were traced through the code by hand and by the review subagent.
  • Did not show here that the new stay-quiet cases fail on the base commit (hook-precision repro-first), because no test could run. By reading the code: before the change rdt_hd_reader returned 1 for every git prefix, so the body was scanned and its backticked rm blocked. The PR body asks the human m
  • Scope-fence deviation: besides rdt_hd_reader and its comment, this changes two lines of the #6625 block comment in the same hook and one sentence of plugins/guardrails/README.md, which would otherwise still say only cat or gh bodies are skipped. It also adds the -- stop and the quote/backslash
  • new-changelog-fragment could not name the fragment (HEAD is detached), so the fragment was written by hand in the existing format; check-changelog-fragments accepts it.
  • check-affected skipped typos (not installed) and three validate-plugins steps that run code from the checked tree, and listed many checks as CI only (including shellcheck-style composites); they are left to the PR's CI.

Fix

  • plugins/guardrails/hooks/block-root-delete-target.sh: rdt_hd_reader gains a git branch: word 1 must be commit or tag, and the later words must hold -F followed by -, before any --, in a prefix with no quote or backslash. Its comment keeps the !sh reason for every other git word and say
  • plugins/guardrails/hooks/block-root-delete-target.test.sh: 2 new stay-quiet cases (git commit -F -, git tag -F - v1.0.0, each body holding a backticked rm -rf /) and 10 new block cases (git -c alias.x=y commit -F -, git -C /tmp commit -F -, unknown alias git ci -F -, git notes add -F -
  • plugins/guardrails/README.md: the substitution-count paragraph says a quoted heredoc body is not read as commands when the whole command is one cat, gh, git commit -F - or git tag -F - line, instead of only cat or gh.
  • .changes/guardrails/fix-7379-git-commit-heredoc-data-7379c0de.md: new patch fragment under Fixed.

Verification

The runner ran each check from the base copy against b1391dd:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • read https: //git-scm.com/docs/git-config: alias.* says 'aliases that hide existing Git commands are ignored except for deprecated commands', and an expansion prefixed with '!' runs as a shell command
  • read https: //git-scm.com/docs/git-commit: -F <file> / --file=<file> takes the commit message from <file>, and '-' reads it from standard input
  • read https: //git-scm.com/docs/git-tag: -F <file> / --file=<file> takes the tag message from <file>, and '-' reads it from standard input
  • .lane/checks/bin/check-changelog-fragments: all 100 fragments under .changes/ valid (run before and after the review fixes)
  • .lane/checks/bin/check-affected: 10 passed, 6 skipped, 0 failed over 4 changed files (run before and after the review fixes)
  • .lane/verify/bin/cant-fail-scan --file plugins/guardrails/hooks/block-root-delete-target.test.sh --check: PASS, no gating findings
  • fresh-context review subagent over the full diff: no blocking bugs. One low-severity finding (a -F - after -- or inside quotes matched though git reads those words as paths) and two nits (README reflow, test-comment accuracy); all three fixed. On reading the code, the guard scans only a quoted b
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40208797818

Left out: the items under Not verified.

Related

#7379

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed b1391dd0bf7c07a8621d37bda0440a036b49d288: 0 finding(s), 0 as inline comments.

No security issues found in this pull request.

critical-findings: 0

What changed. rdt_hd_reader in plugins/guardrails/hooks/block-root-delete-target.sh now also treats a quoted heredoc body as data when the whole command is a one-line git commit … -F - or git tag … -F -. The same change is mirrored in the README, a changelog fragment and tests.

Why I judged the relaxation safe.

  • Gating: The match is the last step in a chain that has already passed several checks:
    • The prefix passes rdt_hd_plain, so it holds none of ; & | ( ) \ $ < >`.
    • The opener is on the first line, at top level and not nested.
    • The delimiter is a plain quoted word.
    • Nothing but whitespace follows the body.
  • Command word: Word 0 must be literally git and word 1 must be commit or tag. That excludes an inline VAR=… git, a launcher or env, and a global option such as -c or -C, which could define an alias. Git ignores an alias that shadows a built-in, so commit and tag cannot be redirected to !sh.
  • Quotes, backslashes and --: The new quote/backslash/-- guard stops the blank-split words from disagreeing with how the shell tokenizes the prefix.
  • What git does with the body: Git reads the heredoc body only as a message. It does not execute stdin for commit or tag. A hostile body also remains scanned in every shape that could run it: a pipe, a redirect, a later-line opener, or any other subcommand. The added tests cover each of these.
  • Look-alikes: commit-tree, --file=- and -F not followed by - all return 1, so they stay scanned.

I found no bypass in the changed lines. A body reaches the inert path only when git consumes it as a message.

Manifests and trusted paths: None of the four changed files is a plugin manifest. None matches the trusted-path globs. The skip-gate "no security surface" rule did not apply because this change relaxes a guard hook. I read the whole change for that reason.

Cost: None. The change adds no billed resource or paid setting, and spends no extra prepaid credit.

Not done: I could not run block-root-delete-target.test.sh. I traced the new cases through rdt_scan_substitutions by reading the code only. I did not read the instruction-exception register in depth, because the diff relaxes a hook scan and does not delete a standing instruction.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed b1391dd0bf7c07a8621d37bda0440a036b49d288: 0 finding(s), 0 as inline comments.

No findings. I read the diff (4 files) and the PR context. I traced the new git branch in rdt_hd_reader against its call site in rdt_scan_substitutions (plugins/guardrails/hooks/block-root-delete-target.sh, lines 3398-3412 and 3518-3525). I did not run the test suite, because I have no shell here.

Code trace

  • git commit -F - and git tag -F -: the new stay-quiet cases (git commit -F - <<'EOF' and git tag -F - v1.0.0 <<'EOF') return 0 in rdt_hd_reader. The existing rdt_hd_plain and quoted-delimiter checks at the call site still gate them. Before this change every git prefix returned 1, so these bodies were scanned.
  • Word 1 must be commit or tag: a global option (-c, -C, --git-dir), an unknown alias, or another subcommand such as notes fails that check and stays scanned.
  • Quote or backslash in the prefix: this returns 1 before the subcommand check, so a joined "a -F - b" word cannot match. It also covers the \-newline form whose opener sits on a later line.
  • -- before -F -: this returns 1. The -F match is tested after the -- check on each word, so -F - ahead of -- still matches, which is correct.
  • -F as the second-to-last word: the loop bound j + 1 < ${#hr_words[@]} still lets it match, so there is no off-by-one.
  • Residual cases: git commit -m -F - also matches, but the body is then unread data and nothing executes it. A hook or config that runs a shell comes from the repository, not from the command line being scanned.

Closing issue #7379 criteria

  • The two stay-quiet cases are in the diff, and each body names rm -rf /.
  • The block cases for git -c alias.x=y, git -C /tmp, an unknown alias (git ci), and the later-line opener with --trailer are in the test file. The extra cases (notes add, --, quoted, --file=-, pipe to sh, redirected cat) are also there.
  • bash <<'EOF' is not changed by this diff.
  • The PR body asks the human merger to confirm the new cases fail on the base commit, and it carries Hold: a human merges this.
  • Unverified: whether block-root-delete-target.test.sh passes in CI, and that the stay-quiet cases fail on the base commit. The PR body itself says neither was run. I only traced both by reading the code.
  • Scope-fence deviation: the PR also edits two lines of the fix(guardrails): block-root-delete-target judges backticks inside a quoted heredoc body #6625 block comment and one README sentence. The PR body discloses this. Both edits keep the docs accurate and are not a finding.
  • Changelog fragment: it is a bump: patch fix, which is a fair level for a precision fix in a guard. Its text matches the implemented behavior.

Other

  • No manifest changes: manifest <field> items do not apply.
  • No path in the trusted-path list was changed.
  • No hold: nothing here can start a real charge, and I found no critical security issue. The change narrows what the guard scans, but only for the one-line, plain-prefix, quoted-delimiter form where git treats the body as a message.
  • The PR text contains no embedded instructions aimed at the reviewer.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head b1391dd0bf7c07a8621d37bda0440a036b49d288.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit e3255a0 Oct 25, 2026
45 of 46 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-7379-40208797818-1 branch October 25, 2026 16:41
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head b1391dd0bf7c07a8621d37bda0440a036b49d288. The lanes clear this reason on their own; the next scheduled run judges it again.

pr-merge's gate holds it on its risk score (evidence-unbound:claude-review: not bound: no-run; evidence-unbound:claude-security-review: not bound: no-run)

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.

fix(guardrails): treat the heredoc body of git commit -F - and git tag -F - as data in block-root-delete-target

0 participants