Repository navigation
Check a session's browser grants when it's created - #115
Open
samuelcole wants to merge 4 commits into
Open
samuelcole wants to merge 4 commits into
samuelcole wants to merge 4 commits into
Conversation
… its grant at creation handleSessionsCreate checks model:prompt and mcp:tools.call before creating a session, but not the matching browser:activeTab.* grant for a requested browser capability, so a session can report browser access the origin never granted. These tests, and the mock's matching case, are red against today's code; the fix follows in a separate commit.
…(HBR-159) handleSessionsCreate checked only model:prompt and mcp:tools.call before creating a session, so a requested browser capability (agent.sessions.create or the browser.* actions requestCapabilities() builds from) sailed through with no grant check. Harbor's session.create page gate then ran its browser checks with upstreamConsent: 'origin-grant', trusting that the page API had already checked the grant — which it hadn't. With no stored grant the check passed at Tier 9 and the audit recorded the site's grant as having allowed it, though the site held none. handleSessionsCreate now requires the matching browser:activeTab.* grant for each requested browser capability, the same way it already requires model:prompt and mcp:tools.call, refusing with ERR_PERMISSION_DENIED when it's missing. Each browser call still checks its own grant again when it's made. The generated test harness's mock matches this, and docs/PERMISSIONS.md, docs/TESTING_YOUR_APP.md and the harness README no longer describe the gap. Co-Authored-By: Claude Sonnet 5 (Claude Code) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (Claude Code) <noreply@anthropic.com>
requestCapabilities (and the test mock) turned browser.read.screenshot into both read and screenshot access, needing both grants. A screenshot call checks only browser:activeTab.screenshot, and now that session creation checks browser grants, a site holding just that grant couldn't get a screenshot session. A screenshot now asks only for screenshot access. Also updates requestCapabilities' comment: session creation now checks browser grants too. Co-Authored-By: Claude Opus 5.5 (Claude Code) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes HBR-159
Problem
When a page created a session with browser access (
agent.sessions.create({ capabilities: { browser: [...] } }), oragent.requestCapabilities()with abrowser.*action),page-api/handlers/session-handlers.tschecked only the model and tool grants. Harbor'ssession.creategate then ran the browser checks withupstreamConsent: 'origin-grant', telling the policy engine the page API had already checked the grant, which it hadn't. With no grant stored, the check passed and the audit log recordedconsent: "origin-grant".So a session could report browser access the site didn't hold, and the Activity feed said the site's grant allowed it. It wasn't a way around a grant: each browser call checks its own grant. But the session and the audit were wrong.
Change
handleSessionsCreatenow requires the matching grant for each browser capability (read →browser:activeTab.read, interact →browser:activeTab.interact, screenshot →browser:activeTab.screenshot, the same mapping live sessions use). A missing grant refuses withERR_PERMISSION_DENIEDbefore Harbor'ssession.createruns, so the gate's "origin grant already checked" is now true. Optional browser capabilities are still left out quietly byrequestCapabilities().requestCapabilities()asked for read access along with any screenshot, so with the new check a site holding only the screenshot grant couldn't get a screenshot session. A screenshot now asks only for screenshot access, the one grant a screenshot call checks.spec/testing/harness-template/mock.js) requires browser grants the same way and uses the same screenshot mapping. Its docs no longer list that as a difference from Harbor.docs/PERMISSIONS.md,docs/TESTING_YOUR_APP.md, the harness README and the changelog.Testing
session.create; the harness example), then f63a6b6 for screenshots (request-capabilities-optional.test.ts,example.capabilities.test.mjs).npx vitest run: 144 files, 1612 tests pass. Harness examples: 26 pass.npm run buildandnpm run build:chromesucceed. tsc has the same errors as the base.tests/e2e): 21/21 pass.demo/ortests/e2e/creates sessions with browser access, so nothing there changes behaviour.Process note
While building, the worker briefly ran
git stashandgit commit --amend, both against this repo's rules. It caught both before anything was pushed. The stash was popped and confirmed empty, and the final commits are correct. Nothing was lost or rewritten on the remote.This PR was opened by an AI agent (Claude Code) working for the maintainer.
🤖 Generated with Claude Code