Repository navigation
fix(permissions): preserve strict all-tools rules under last-match evaluation - #3866
Merged
dyoshikawa merged 2 commits intoNov 18, 2026
Merged
dyoshikawa merged 2 commits into
dyoshikawa merged 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical authorization bug remains because a global all-tools deny can be overridden by a later category-specific allow when no pattern-specific restrictions exist.
1 open issue
What changed in this PR
This PR hardens OpenCode/Kilo permission generation under last-match-wins evaluation by ordering all-tools rules from least to most restrictive and preserving catch-all deny handling.
Changes:
- Reorders
*category rules as allow → ask → deny. - Processes all-tools rules even when only a catch-all deny is present.
- Adds focused regression tests for ordering and catch-all deny scenarios.
| File | Description |
|---|---|
| src/features/permissions/last-match-restate.ts | Reorders OpenCode/Kilo all-tools permission rules by strictness and handles catch-all configurations. |
| src/features/permissions/last-match-restate.test.ts | Adds regression coverage for allow, ask, deny, and catch-all rule ordering. |
Review effort: Lite
| action !== "allow" && pattern !== CATCH_ALL_PATTERN && !isPrototypePollutionKey(pattern), | ||
| ); | ||
| if (restrictions.length === 0) { | ||
| if (restrictions.length === 0 && !allToolsRules) { |
4 tasks
Owner
|
@jdotc1 Thank you! |
This was referenced Nov 19, 2026
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.

Addresses the
*-key ordering case in #3822 item 6 (first bullet). Other issues under #3822 remain open.Security fix
OpenCode/Kilo treat permission patterns as last-match-wins. A
*category such as{ ".env": "deny", "*": "allow" }previously emitted the later catch-all allow unchanged, so the explicit restriction could be overridden. Emit all-tools allows first, asks next, and denies last, consistently with Rulesync's stricter-action precedence. Also handle the catch-all deny case when there are no pattern-specific restrictions.This is a narrow, fail-closed reordering: it does not grant any new permission, alter rules for tools without last-match semantics, or address the remaining integer-like-key ordering and category-restatement gaps.
Verification
pnpm exec vp test run src/features/permissions --silent=true— 2,869 passed across 59 files.pnpm run typecheck— passed.pnpm exec vp fmt --check ...andpnpm exec vp lint ... --max-warnings 0— passed.