Skip to content

fix(hooks): preserve host checks when settings cannot be loaded - #4680

Open
Ehsan-hash wants to merge 1 commit into
rtk-ai:developfrom
Ehsan-hash:fix/settings-read-fail-closed
Open

Ehsan-hash wants to merge 1 commit into
rtk-ai:developfrom
Ehsan-hash:fix/settings-read-fail-closed

Conversation

@Ehsan-hash

Copy link
Copy Markdown

Summary

  • Leave commands unchanged for Cursor and Droid when an existing permission settings file cannot be read or parsed, so rewriting cannot bypass a rule RTK failed to load.
  • Distinguish absent/empty settings from failed reads. Preserve valid rules and Gemini's existing behavior.

Fixes #4652.

Test plan

  • cargo fmt --all -- --check, standalone proxy formatting, cargo clippy --all-targets -- -D warnings, and cargo test --all (5,006 passed, 8 ignored).
  • Original-code reproduction: the new CLI tests fail for both Cursor and Droid on 6c1af5fb; they pass with this change.
  • Actual hook CLI checks with isolated synthetic settings: valid allow/deny rules, missing/empty files, malformed JSON, read errors, and all four Droid settings locations. A confirmed git diff rewrite distinguishes pass-through from an already-unrewritable command.
  • Separately inspected actual Cursor/Droid CLI responses and read/parse warnings. No command payloads were executed and no personal settings were used.

Prepared with AI assistance and independently reviewed. Local checks cover RTK's hook protocol; they do not claim a live Cursor or Droid permission decision. This hook change still needs the repository's two maintainer reviews.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working hooks security labels Oct 20, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🔴 Risk high

Summary

Fixes a fail-open bug in RTK's hook permission loading: when a Cursor or Droid settings file exists but fails to be read or parsed, the code now fails closed (denies all commands) instead of silently treating the error as 'no rules'. Also distinguishes missing/empty settings files from read/parse errors, and preserves existing behavior for Gemini.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4652


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working hooks security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor, Gemini and Droid permission loaders drop an unreadable or unparseable settings file's rules

1 participant