Skip to content

browser: config deny for browser permission is overridden by plugin-appended allow rule #56869

Closed as duplicate

Description

@engineering-ainbin

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 (TERM set; TERM_PROGRAM and COLORTERM unset)
  • Shell: C:\Windows\system32\cmd.exe
  • Install/channel: latest (desktop app, resources/opencode-cli.exe)
  • Active plugins: @dietrichgebert/ponytail, opencode-caveman

Reproduction

  1. In opencode.json (or C:\ProgramData\opencode\opencode.json), add:
    "permissions": [
      { "action": "browser", "resource": "*", "effect": "deny" }
    ]
  2. Start a session in the desktop app.
  3. Inspect the Code Mode tool catalog (it is injected into the agent's
    instructions). Browser tools such as browser.tabs.open are still listed.
  4. Call a browser tool through Code Mode execute, e.g.
    tools.browser.tabs.open({ url: "https://example.com" }).
  5. 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):

  1. 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";
    };
  2. Browser tools register with the correct permission id:

    options: {
      namespace: h < 0 ? "browser" : `browser.${l.name.slice(0, h)}`,
      permission: "browser",
      codemode: true,
    }
  3. 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" })));
  4. 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
    no allow for the execute action 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 allow override an explicit user deny for 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 allow when the agent/session ruleset
      contains a deny for browser.
  • Workaround tried: documenting "do not use the browser tools" in agent
    instructions. This is policy only and not enforced.

Activity

  1. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    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 global opencode.json permissions deny is overridden the same way, which is what you're seeing on 2.0.32.

    Possible duplicates and related issues, ordered by likelihood:

    If 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.

  2. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    Contributor

    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: allow is added, and it overrides browser denies set in the agent and in opencode.json. Please follow #54044 for updates. Details from your report, like the Windows desktop setup and the execute deny 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions