anomalyco / anomalyco/opencode

permission: broad deny overrides specific allow via findLast() semantics

Open
#37,935 1 comment 0 reactions 1 assignee View on GitHub

@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
  1. Configure opencode.jsonc with:
    "external_directory": {
      "$HOME/utilities/*": "allow",
      "$HOME/*": "deny"
    }
    
  2. Try accessing a file under /home/m/Projects/tools/paper-making-system/
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.