Skip to content

fix(hooks): ensure default permission verdict prompts user for confirmation - #1173

Merged
FlorianBruniaux merged 1 commit into
rtk-ai:developfrom
iRonin:fix/hook-auto-allow-bypass
Apr 13, 2026
Merged

FlorianBruniaux merged 1 commit into
rtk-ai:developfrom
iRonin:fix/hook-auto-allow-bypass

Conversation

@iRonin

@iRonin iRonin commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Verifies that PermissionVerdict::Default (returned when no permission rule matches) correctly maps to exit code 3 (ask), NOT exit code 0 (auto-allow).

Analysis

Reviewed three key files:

  1. src/hooks/rewrite_cmd.rs — The match arm on line 37 already groups Default with Ask, both returning exit code 3. The code was already correct.
  2. src/hooks/permissions.rs — Default is properly documented as "no rule matched — default to ask" with least-privilege semantics.
  3. .claude/hooks/rtk-rewrite.sh — Exit code 3 correctly omits permissionDecision, forcing Claude Code to prompt the user.

Changes

Added 6 comprehensive regression tests in src/hooks/rewrite_cmd.rs under a new exit_code_protocol test module:

  • test_default_verdict_maps_to_ask_exit_code — verifies Default → exit 3
  • test_allow_verdict_maps_to_allow_exit_code — verifies Allow → exit 0
  • test_ask_verdict_maps_to_ask_exit_code — verifies Ask → exit 3
  • test_deny_verdict_maps_to_deny_exit_code — verifies Deny → exit 2
  • test_no_auto_allow_bypass_for_unrecognized_commands — end-to-end security test for issue security: hook auto-allow bypasses agent permission model for rewritten commands #1155
  • test_default_never_equals_allow — sentinel to catch enum changes

All tests include security-focused documentation referencing this issue.

Verification

cargo fmt --all && cargo clippy --all-targets && cargo test --all

All 1356 tests pass (6 new + 1350 existing), zero clippy warnings in modified files.

@iRonin
iRonin changed the base branch from master to develop April 10, 2026 13:10
@iRonin
iRonin force-pushed the fix/hook-auto-allow-bypass branch from d0fbae5 to a839d59 Compare April 10, 2026 17:49
@iRonin
iRonin force-pushed the fix/hook-auto-allow-bypass branch from a839d59 to 40462c0 Compare April 10, 2026 17:54

@FlorianBruniaux FlorianBruniaux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — security fix, reviewed diff, tests pass.

@FlorianBruniaux
FlorianBruniaux merged commit 8f28a05 into rtk-ai:develop Apr 13, 2026
1 check passed
@mhcoen mhcoen mentioned this pull request Apr 17, 2026
thehoff pushed a commit to thehoff/contextcrawler that referenced this pull request May 14, 2026
thehoff pushed a commit to thehoff/contextcrawler that referenced this pull request May 14, 2026
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.

2 participants