Repository navigation
Description
Summary
A deny rule for the browser permission in opencode.json is silently
overridden, so browser tools stay visible in the Code Mode catalog and remain
callable. The desktop app appends an allow rule to the session when it attaches
a browser tunnel, and the deny check uses findLast (last match wins), so the
appended allow beats both the user's config deny and the plugin's own
agent-level deny.
Impact: a user who explicitly denies browser access cannot rely on the config
deny. There is no way to block the browser tools via the documented permission
config while the desktop browser tunnel is attached.
Environment
- opencode version: 2.0.32
- OS: Windows 10.0.26200.7171 (win32 x64)
- Terminal: xterm-256color (
TERMset;TERM_PROGRAMandCOLORTERMunset) - Shell: C:\Windows\system32\cmd.exe
- Install/channel: latest (desktop app,
resources/opencode-cli.exe) - Active plugins:
@dietrichgebert/ponytail,opencode-caveman
Reproduction
- In
opencode.json(orC:\ProgramData\opencode\opencode.json), add:"permissions": [ { "action": "browser", "resource": "*", "effect": "deny" } ]
- Start a session in the desktop app.
- Inspect the Code Mode tool catalog (it is injected into the agent's
instructions). Browser tools such asbrowser.tabs.openare still listed. - Call a browser tool through Code Mode
execute, e.g.
tools.browser.tabs.open({ url: "https://example.com" }). - The call succeeds and a tab is opened, despite the deny rule.
Consistently reproducible.
Expected Behavior
With { "action": "browser", "resource": "*", "effect": "deny" }, the browser
tools should be removed from the Code Mode catalog and any attempt to call them
should be rejected.
Actual Behavior
Browser tools remain in the catalog and execute normally.
Relevant code paths in opencode-cli.exe v2.0.32 (decompiled strings for
reference):
-
The deny filter for the Code Mode catalog, in the tool registry
snapshot:let x = f ?? []; // permission ruleset passed in for (let [ie, oe] of y.tools) { if (ku(oe.options?.permission ?? ie, x)) continue; // drop denied tools ... }
and the matcher itself, which takes the last matching rule:
ku = (e, r) => { let n = r.findLast((i) => ab(e, i.action)); return n?.resource === "*" && n?.effect === "deny"; };
-
Browser tools register with the correct permission id:
options: { namespace: h < 0 ? "browser" : `browser.${l.name.slice(0, h)}`, permission: "browser", codemode: true, }
-
The browser plugin already pushes a default deny onto every agent, which is
the intended gate:// BrowserConnection.make yield* e.agent.transform((_) => _.list().forEach((A) => A.permissions.push({ action: "browser", resource: "*", effect: "deny" })));
-
But the attach RPC of the same plugin appends an allow to the session
permissions:attach: (_, A) => H(function* () { ... return yield* i(_.sessionID), // i() does: // e.session.update({ permissions: [...A.permissions ?? [], // { action: "browser", resource: "*", effect: "allow" }] }) ... })
Because ku uses findLast, the allow appended by the attach flow is the last
match and wins, so ku("browser", rules) returns false and the tools are kept.
This defeats the user's config deny (and the plugin's own agent-level deny) for
any session with an attached browser tunnel.
Note: browser tools are registered with codemode: true, so they are reachable
only through the Code Mode execute tool, not as top-level tool definitions.
Additional Context
- Related observation: the only currently effective way to block the browser
tools is{ "action": "execute", "resource": "*", "effect": "deny" }, because
noallowfor theexecuteaction is ever appended. This works but disables
Code Mode entirely, including other namespaces (e.g. MCP servers exposed
through Code Mode). - Suggested directions:
- Do not let a plugin-appended
allowoverride an explicit userdenyfor the
same action/resource, or - Prefer explicit/specific user rules over plugin defaults instead of
last-match-wins, or - Have the attach flow refuse to append
allowwhen the agent/session ruleset
contains adenyforbrowser.
- Do not let a plugin-appended
- Workaround tried: documenting "do not use the browser tools" in agent
instructions. This is policy only and not enforced.
Activity
opencode-agent commentedon Oct 18, 2026
Thanks for the detailed report and code trace! I think this is a duplicate of #54044. It describes the same mechanism: when a desktop browser attaches, the browser plugin adds a session-level
{ "action": "browser", "resource": "*", "effect": "allow" }. Because the last matching rule wins, that allow overrides earlier denies. A comment there also confirms that a globalopencode.jsonpermissionsdeny is overridden the same way, which is what you're seeing on 2.0.32.Possible duplicates and related issues, ordered by likelihood:
findLast) permission evaluationtool.usepolicy cannot deny theexecute(Code Mode) tool:execute:*,executeand*are all ignored, whileshell:*and*do blockshell#56349:tool.usepolicies cannot deny theexecute(Code Mode) toolIf you have extra details, such as the Windows/desktop setup or the workaround of denying
execute, adding them to #54044 would help. The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.opencode-agent commentedon Oct 19, 2026
We haven't heard back, so I'm closing this as a duplicate of #54044. That issue tracks the same problem: when a desktop browser attaches, a session-level
browser: allowis added, and it overridesbrowserdenies set in the agent and inopencode.json. Please follow #54044 for updates. Details from your report, like the Windows desktop setup and theexecutedeny workaround, would be useful there. If your problem turns out to be different, reply here and we can reopen this. Thanks again for the thorough write-up!