chore(hardening): enforce configured permission rules and fail closed on approval - #2
Merged
Merged
Conversation
… on approval Seed each agent scope with the user's [permission] rules at bootstrap, next to where the default permission mode is applied. The permission.rules.add Op is not persisted, so the rules model always started empty and a configured allow/deny/ask never reached the policy chain. Move the sensitive-file and git-control asks ahead of the blanket auto-mode approval in the policy chain so auto mode does not waive them. Session approval history and user allow rules keep their existing precedence, so an already-approved access does not re-prompt. Treat a missing approval broker as a denial rather than an approval: if a policy decided a call needs confirmation and there is nobody to ask, the call is blocked. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
Three gaps in how the v2 permission layer enforces its own configuration:
[permission]rules were inert. The config section parsesdeny/allow/askinto rules, and theuser-configured-*policies read them — butaddRuleshad no caller anywhere in the repo, and the backing Op ispersist: false, so the model always stayed empty. An operator settingdeny = ["Bash"]got a silent no-op.auto-mode-approvesat at position 3 in the policy chain, ahead ofsensitive-file-access-ask(7) andgit-control-path-access-ask(8), so neither was reachable once auto mode was on.ISessionApprovalServicesilently auto-approved every call that reached the ask path.What changed
agentLifecycleService.bindBootstrap), immediately after the existingdefaultPermissionModeseeding and using the sameIConfigServicepattern. Because the Op is not persisted, seeding happens per agent scope.auto-mode-approvesits after the sensitive-file and git-control asks. Deliberately minimal:session-approval-historyanduser-configured-allowkeep their existing precedence over the asks, so anything already approved (or explicitly allowed by the user) does not start re-prompting. Only the auto-mode blanket approval moved.requestToolApprovalwhen no broker is bound — the request resolves to a veto rather than an approval.Behaviour change worth flagging to reviewers
Auto mode (including headless
-p, which sets it) will now prompt on sensitive-file and.gitcontrol-path access instead of proceeding silently. That is the intent, but it means an unattended run that touches those paths will now block on a prompt rather than continue. Worth knowing before this is wired into any automation.Testing
agent-core-v2suite green: 310 files / 4875 tests, so the chain reorder causes no regressions elsewhere.oxlintandtsc --noEmitclean.Checklist
minor— behavioural change).