anomalyco / anomalyco/opencode
permission: broad deny overrides specific allow via findLast() semantics
@jlongster is already working on this.
Since Jul 20, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
When a broad deny rule (e.g., $HOME/* → deny) appears in the same ruleset as a more specific allow (e.g., $HOME/utilities/* → allow), the evaluate() function uses findLast() which picks the last matching rule — regardless of pattern specificity. The broad deny silently overrides the specific allow, making it impossible to use the pattern "deny everything under a parent path except specific subdirectories."
This affects both V1 (packages/opencode/src/permission/index.ts) and V2 (packages/core/src/permission.ts) permission evaluation, and also means any "always" saved approvals under a broadly denied parent are effectively dead code.
Plugins
None
OpenCode version
dev branch (source)
Steps to reproduce
- Configure opencode.jsonc with:
"external_directory": { "$HOME/utilities/*": "allow", "$HOME/*": "deny" } - Try accessing a file under
/home/m/Projects/tools/paper-making-system/ - Access is denied — the
$HOME/*deny wins because it appears later in the ruleset
Screenshot and/or share link
N/A
Operating System
Linux
Terminal
N/A (configuration issue)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.