Repository navigation
fix: fail closed when permissions settings file cannot be read or parsed (fixes #4282) - #4321
Closed
TechWizard9999 wants to merge 12 commits into
Closed
TechWizard9999 wants to merge 12 commits into
TechWizard9999 wants to merge 12 commits into
Conversation
…s empty Only insert the newline separator between body and hint when the filtered body is non-empty. Fixes rtk-ai#4159.
- Add ConfigError verdict for unreadable/unparseable settings files - load_permission_rules now returns config_error flag when file exists but cannot be read/parsed - ConfigError verdict maps to Deny (fail closed) in decide_with_params - Error messages use 'error' level (not 'warning') so they're visible even when hooks redirect stderr - Fixes rtk-ai#4282
- Fix load_rules_for callers to handle 4-tuple return - Add ConfigError case to expected_exit_code in rewrite_cmd.rs - Add test for ConfigError exit code mapping
Contributor
Author
📊 Automated PR Analysis
SummaryFixes an issue where a Claude settings.json file that exists but is unreadable or contains invalid JSON caused its permission rules to be silently dropped, resulting in a permissive Default verdict instead of enforcing the intended deny rules. The PR introduces a ConfigError verdict that maps to Deny (fail closed) whenever a settings file exists but cannot be read or parsed, and includes an unrelated small fix/tests in runner.rs's emit_guarded for hint formatting when filtered output is empty. Review Checklist
Linked issues: #4282 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
Contributor
Author
Collaborator
|
Thanks for keeping the backlog clean! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4282: When a settings.json file exists but cannot be read (permission denied) or parsed (JSON syntax error), its deny/ask/allow rules are silently dropped. Commands that should be denied instead receive Default verdict (exit 3).
Changes
src/hooks/permissions.rs:
src/hooks/decision.rs:
src/hooks/rewrite_cmd.rs:
Behavior Change
This ensures that a broken security configuration cannot silently degrade to permissive behavior. For distinguishing hosts (Claude, Cursor), the command is now properly denied. For non-distinguishing delegates, the behavior is unchanged (exit 2 treated as passthrough).