Skip to content

fix(opencode): prevent approved wildcard from overriding config deny rules#31541

Open
de-mh wants to merge 1 commit into
anomalyco:devfrom
de-mh:fix/permission-deny-override
Open

fix(opencode): prevent approved wildcard from overriding config deny rules#31541
de-mh wants to merge 1 commit into
anomalyco:devfrom
de-mh:fix/permission-deny-override

Conversation

@de-mh

@de-mh de-mh commented Jun 9, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #31540

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a user clicks "Allow always" on an edit permission prompt, always: ["*"] stores {permission: "edit", pattern: "*", action: "allow"} in the approved list. Permission.ask() calls evaluate(permission, pattern, ruleset, approved) which flattens to [...ruleset, ...approved] and uses findLast — the approved wildcard always wins over config deny rules.
Fix: evaluate config deny rules (ruleset-only) before the combined evaluation. If the config explicitly denies a pattern, DeniedError fires immediately regardless of runtime approvals.

How did you verify your code works?

  • Added integration test that first approves with "always", then verifies a config-denied pattern still throws DeniedError
  • All 81 existing permission tests pass
  • bun typecheck clean

Screenshots / recordings

N/A — logic fix, no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

…rules

When a user clicks 'Allow always' for an edit, the approved list stores
{permission: 'edit', pattern: '*', action: 'allow'}. Because evaluate()
uses findLast across [...ruleset, ...approved], this broad allow always
wins over specific deny rules from the user config.

Fix: check config deny rules (ruleset-only evaluation) before checking
the combined ruleset+approved. Explicit deny in config is absolute and
cannot be overridden by runtime approvals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permission deny rules overridden by 'Allow always' approval

1 participant