GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(browser): keep a configured browser deny when the desktop attaches by Hona · Pull Request #63614 · anomalyco/opencode Conversation
|
| Before | After | |
|---|---|---|
Agent or config denies browser, desktop attached |
calls run | refused with [browser.denied] |
tool.use policy on browser |
never evaluated | evaluated (permission.assert) on every call |
| Subagent of an attached session | grant inherited, calls fail as disconnected | grant removed when its first prompt is admitted |
| Server killed while attached | grant stays in the session | removed at startup, before the RPC registers |
| No deny configured | works on attach, no prompt | unchanged |
connection.ts authorize): the plugin records each agent's own rules before it appends its default deny. Before a browser call it refuses if those rules, or the session's rules without the grant, deny browser; then it asserts the permission so policies run.prompt hook removes the inherited grant from a child that has no attachment of its own, under the attachment lock, before any step runs.// Several servers can share one database: never revoke a live process's grant, or another host's. function running(owner: typeof GrantOwner.Type) { if (owner.host !== hostname()) return true ...process.kill(owner.pid, 0) }
plugin-browser. Subagent and stale-grant fixes become unnecessary there; the deny fix needs browser rules aliased to the new browser_* tool names.packages/core/test/browser-permission.test.ts drives the real plugin, config files and permission service with a stand-in desktop.<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"> <rect x="10" y="22" width="70" height="28" rx="5" opacity=".5"/> <path d="M22 36h46" opacity=".5"/> <rect x="160" y="14" width="70" height="44" rx="5" opacity=".5"/> <path d="M170 24h36M170 34h50M170 44h28" opacity=".35"/> <path d="M84 36h30" opacity=".6" stroke-dasharray="3 5"> <animate attributeName="stroke-dashoffset" values="16;0" dur="1s" repeatCount="indefinite"/> </path> <circle cx="134" cy="36" r="14" opacity=".9"/> <path d="M124 46l20-20" opacity=".9" stroke-width="2"/> <path d="M152 36h4" opacity=".2"/> <circle cx="134" cy="36" r="14" opacity="0"> <animate attributeName="r" values="14;22" dur="2s" repeatCount="indefinite"/> <animate attributeName="opacity" values=".5;0" dur="2s" repeatCount="indefinite"/> </circle> </svg>
Added by the opencode bot (AI-generated).
Related: #55795
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…tach grant Attaching a desktop browser writes browser:* and skill:browser allows into the session's permissions. Session rules are evaluated after agent rules, so the grant overrode a browser deny from config, an agent definition (for example a "*" deny) or the session itself. Browser tools never called the permission check either, so tool.use policies did not apply. The plugin now records each agent's rules before it appends its own default deny. A browser call is refused when those rules, plus the session's rules without the grant, deny the browser, decided the way core's tool filter decides. The call then runs the permission check with the operation as its resource, so permission.evaluate hooks such as tool.use policies apply. Sessions without a deny behave as before: the grant allows the check, so nothing prompts. Refs #54044, #53294, #56869
…rent A child session copies its parent's permissions, so a subagent spawned from an attached session got the browser:* and skill:browser allows but no attachment. It listed the browser tools and the Browser skill, every call failed with [browser.disconnected], and the copied allow outlived the parent's attachment. The plugin now revokes the grant from a child session while the child's prompt is admitted (session prompt hook), before any step of the child can list the tools, so there is no race with its first step. It holds the attachment lock while it checks and writes, and skips a child that has an attachment of its own. A subagent whose agent denies the browser stays denied even when the desktop attaches to it, through the check from the previous commit. Refs #61238
…illed The attach grant is a stored session rule, but its revoke runs only from the plugin's finalizer. After SIGKILL, a crash or a stop timeout, the session kept browser:* and skill:browser allows with no attachment behind them, so the next server listed the browser tools and every call failed with [browser.disconnected]. Each grant is now recorded in plugin storage with the server process that wrote it (host and process ID) and its location, before the grant is written; a successful revoke removes the record. When the plugin starts for a location, and before it registers the browser RPC so no attach can race it, it revokes the grants recorded for that location by a process that no longer runs. Several server processes can share one database (a desktop's server and a manual `opencode serve` both use opencode.db), so a sweep of every session in the location could revoke another server's live grant. The sweep skips records of a running process and of another host, which cannot be checked. Grants written before this change have no record and are left alone; the next attach and detach of their session removes them. The startup sweep before RPC registration, its location scoping and ignoring per-session failures come from #61639. Fixes #61609 Co-authored-by: Chen Yufeiyang <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Whole-browser denies, inherited subagent grants and stale grants after a kill are all handled. I checked with the new browser-permission tests: 6 of the 7 cases I could run on the base fail there (the eighth needs the new export), and all 8 pass with this PR. bun test in plugin-browser passes, and tsc --noEmit there is clean. The package's typecheck script fails here with Script not found "check", so I couldn't type-check core. I couldn't run an end-to-end repro: the serve + attach RPC script from #61609 got RPC is unavailable: experimental.browser on both checkouts, and the desktop app can't run here.
Public API: unchanged. Browser calls now go through permission.assert, so tool.use policies apply. There is a new [browser.denied] tool error and internal plugin storage keys (grant:<sessionID>).
One concern, inline: the pre-check only catches a deny on all of browser. A deny or ask on a single operation is still overridden by the attach grant.
Related: #55795
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ...(configured.get(tool.agent) ?? []), | ||
| ...(session.permissions ?? []).filter((rule) => !BrowserMachine.isGrant(rule)), | ||
| ] | ||
| if (BrowserMachine.deniesBrowser(rules)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
deniesBrowser only refuses when the last matching rule is a deny on browser with resource *. Two cases still go through the grant:
{ action: "browser", resource: "evaluate", effect: "deny" }, or on files.upload. The permission.assert below adds the session's browser:* allow after it, and that allow wins. I checked this with a throwaway test: a browser:tabs.list deny in opencode.json still let browser.tabs.list run with a desktop attached.browser: ask. The grant turns it into a silent allow.These are probably the next denies users will write. Could this match configured plus the non-grant session rules against browser / operation, the same way assert does, and then refuse on deny or ask on ask, instead of only checking the * case?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Folded into #63002, which now carries these fixes (a configured deny or ask wins over the attach grant per operation, subagents do not inherit the grant, stale grants are swept at startup) with the rest of the browser work. Closing in its favour. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
agents: browser tools exposed despite agent-level "deny browser" when the agent has execute browser tools stay listed after a hard restart leaves a stale session grant Subagents inherit the Desktop browser grant but can't use the parent's attachment browser: config deny for browser permission is overridden by plugin-appended allow rule agents: browser tools exposed despite agent-level "deny browser" when the agent has execute
There was an error while loading. Please reload this page.