You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rules are evaluated by pattern match, with the last matching rule winning. A common pattern is to put the catch-all "*" rule first, and more specific rules after it.
Therefore the below opencode.json should result in a behavior allowing writing to the specified directory but no others, regardless of the root project directory location.
Permission edit patterns #13872: Permission edit patterns — same symptom: "*": "deny" with a specific allow pattern results in no write access anywhere
Took a look at this on the latest dev. The primary symptom you're describing — "*": "deny" followed by "~/Documents/Programming/AI/**": "allow" denying everything — appears to be already fixed by #24308 (fix(config): preserve permission order with Effect decode), merged ~1.5 hours after this issue was filed.
Before #24308, the Effect Schema decode could canonicalise known keys (like *, edit) ahead of the user-written order, so the wildcard *: deny could end up after the specific allow rule in the resulting ruleset, causing it to win. After #24308, decode uses propertyOrder: "original", so the user's key order is preserved at every nesting level.
I reproduced your opencode.json end-to-end on dev (load via Config.Service → Permission.fromConfig → Permission.evaluate) and the actions come out as expected:
You were on 1.14.25, which predates #24308 — please retest on the next release once it ships.
I opened #24361 with a regression test that mirrors your exact config end-to-end (the existing permission config preserves user key order test only covered the outer keys; #24361 also asserts the nested rule key order, which is where this issue reproduces).
Two notes on your second config in the issue body:
That has a duplicate edit key in JSON. Per the JSON spec the second occurrence wins, so the resulting config is edit: { "~/Docs/...": "allow" } with no wildcard deny — which is why you saw "write access to all directories". That's a JSON-level thing, not opencode behavior.
Closing thoughts: if behavior on the next release still doesn't match expectations, please reopen with a small repro and the version, and we can dig in further.
For context, I also have global permission rules set — but they weren't the issue here. My global config has edit set to allow, yet the sub-agent was still prompting me for edit permission, which confirms it was the agent-level rules (specifically the "*": "deny" wildcard) overriding things. Once I dropped the deny wildcard from the agent config, paths outside the allow list default to asking for permission instead of flat-out denying.
I can confirm this is still an issue, and I'm pretty shocked it's been around for so long - permissions not working as documented is a fairly critical security issue, especially if it's failing to block tool calls that the user has intended as denied.
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Activity
github-actions commentedon Apr 25, 2026
This issue might be a duplicate of existing issues. Please check:
*+ specific path allow rules not behaving as expected, same docs section referenced"*": "deny"with a specific allow pattern results in no write access anywhereIf your issue is distinct from the above, feel free to clarify the differences.
tiffanychum commentedon Apr 25, 2026
Took a look at this on the latest
dev. The primary symptom you're describing —"*": "deny"followed by"~/Documents/Programming/AI/**": "allow"denying everything — appears to be already fixed by #24308 (fix(config): preserve permission order with Effect decode), merged ~1.5 hours after this issue was filed.Before #24308, the Effect Schema decode could canonicalise known keys (like
*,edit) ahead of the user-written order, so the wildcard*: denycould end up after the specific allow rule in the resulting ruleset, causing it to win. After #24308, decode usespropertyOrder: "original", so the user's key order is preserved at every nesting level.I reproduced your
opencode.jsonend-to-end ondev(load viaConfig.Service→Permission.fromConfig→Permission.evaluate) and the actions come out as expected:evaluate("edit", "<home>/Documents/Programming/AI/file.md")→allowevaluate("edit", "/some/other/dir/file.md")→denyevaluate("bash", "cd ~/Documents/Programming/AI/x")→allowevaluate("bash", "rm -rf /")→denyYou were on
1.14.25, which predates #24308 — please retest on the next release once it ships.I opened #24361 with a regression test that mirrors your exact config end-to-end (the existing
permission config preserves user key ordertest only covered the outer keys; #24361 also asserts the nested rule key order, which is where this issue reproduces).Two notes on your second config in the issue body:
That has a duplicate
editkey in JSON. Per the JSON spec the second occurrence wins, so the resulting config isedit: { "~/Docs/...": "allow" }with no wildcard deny — which is why you saw "write access to all directories". That's a JSON-level thing, not opencode behavior.Closing thoughts: if behavior on the next release still doesn't match expectations, please reopen with a small repro and the version, and we can dig in further.
matthew-j-hooper commentedon Apr 27, 2026
The first opencode.json still prevents writing to the specified directory on 1.14.27
matthew-j-hooper commentedon May 10, 2026
Confirming that the first config above still behaves in this incorrect way as of v1.14.45
RisaKirisu commentedon May 10, 2026
Encountering this issue as well. Definitely a regression. I reported a similar bug weeks ago and it was fixed, but now it's happening again.
matthew-j-hooper commentedon May 29, 2026
Confirming that the first config above still behaves in this incorrect way as of v1.15.12
socrabytes commentedon Jun 12, 2026
Ran into the same thing on v1.17.4. As a workaround, I removed the
"*": "deny"wildcard and only kept the allow rules in my sub-agent config:For context, I also have global permission rules set — but they weren't the issue here. My global config has edit set to
allow, yet the sub-agent was still prompting me for edit permission, which confirms it was the agent-level rules (specifically the"*": "deny"wildcard) overriding things. Once I dropped the deny wildcard from the agent config, paths outside the allow list default to asking for permission instead of flat-out denying.Not a fix, but gets things unblocked.
tamasys commentedon Jul 16, 2026
I can confirm this is still an issue, and I'm pretty shocked it's been around for so long - permissions not working as documented is a fairly critical security issue, especially if it's failing to block tool calls that the user has intended as denied.
enduro commentedon Aug 6, 2026
still broken on 1.18.14.
Denies to edit/write in projects directory with this config:
fidodido48 commentedon Sep 7, 2026
Yeah, same issue here - this wont work:
This will (for the OC editor only!):
Now AI will bypass this by using bash cmds to work around above editors block, so bash needs to be denied as well:
Additionally, filesystem permissions need to be tightened too:
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊