Skip to content

fix: close flutter-reviewer read-only hook bypasses - #162

Open
HadiHassan22 wants to merge 1 commit into
VeryGoodOpenSource:mainfrom
HadiHassan22:fix/reviewer-readonly-hook-bypass
Open

HadiHassan22 wants to merge 1 commit into
VeryGoodOpenSource:mainfrom
HadiHassan22:fix/reviewer-readonly-hook-bypass

Conversation

@HadiHassan22

@HadiHassan22 HadiHassan22 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #161.

allow-readonly-git.sh keeps the flutter-reviewer agent read-only. It let three kinds of command through:

  • Multi-line commands. A newline separates commands just like ;, but it wasn't in the rejected-operator list, and the allow check passes when any line matches. A git status line anywhere in the command let the other lines run.
  • git diff --output=<file> / --output <file>, which writes the diff to any path.
  • git diff --ext-diff, which runs the configured external diff driver.

What changed

  • Newlines and carriage returns are denied, alongside the operators already rejected.
  • $ is denied outright, extending the existing $( rule. Parameter expansion such as ${X:-…} can produce option text the other checks never see.
  • Any argument starting with --out or --ext is denied, after stripping quotes and backslashes so "--output" or --out\put can't hide the option. --no-ext-diff and --output-indicator-* stay allowed.
  • The docs (README, CLAUDE.md) and the reviewer's prompt list the new restrictions.

The reviewer's normal commands (git status, git diff, git diff --cached, git diff main...HEAD) are unaffected.

Left as-is

Like the other hooks, this one still exits 0 when jq is not installed, which allows every command. I kept that to match the repo convention, but since this hook is the agent's only write guard, you may want it to fail closed instead. Happy to add that here or in a follow-up.

Tests

allow-readonly-git_test.sh gains 14 blocked cases (multi-line commands, both --output forms, quoted and escaped spellings, --ext-diff, $ expansion) and 4 allowed cases to guard against over-blocking. 36/36 pass on bash 3.2 and 5; the 14 new blocked cases all fail against the current hook.

Type of Change

  • New feature (feat)
  • Bug fix (fix)
  • Code refactor (refactor)
  • Documentation (docs)
  • CI change (ci)
  • Chore (chore)

🤖 Generated with Claude Code

@HadiHassan22
HadiHassan22 requested a review from a team as a code owner September 25, 2026 15:53
allow-readonly-git.sh let a mutating command through when it shared a
multi-line command with `git status`/`git diff`, since a newline was not
treated as a separator and the allow check passed if any line matched.
It also allowed `git diff --output` (writes files) and `--ext-diff` (runs
the external diff driver).

Deny newlines, carriage returns and `$` expansion, and deny `--output`
and `--ext-diff` after stripping quotes. Add tests for each case.

Fixes VeryGoodOpenSource#161

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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: flutter-reviewer read-only hook can be bypassed with a newline or git diff --output

1 participant