GeezerVison is showing github.com — fix(browser): partition isolated CefRequestContexts by scope, fail closed, and drop on last tab close by Hona · Pull Request #288 · anomalyco/opencode-rune
Conversation
Summary
Resolves notes/review-rd274.md Finding 5 in the shared apps/browser-engine/src/context.rs pool for WS-1, WS-9 (#274), PREVIEWS (#281), and BROWSER-TOOLS (ahead of Phase 3b):
- Partitioned
CefRequestContext per scope (zero cross-scope sharing):
ContextKind::Default -> global persistent profile (OPENCODE_BROWSER_PROFILE/Default, persist_session_cookies: 1).
ContextKind::Preview { workspace, grant } -> ContextKey::Preview { workspace, grant } (distinct per workspace & grant).
ContextKind::Artifact { artifact_id } -> ContextKey::Artifact(artifact_id) (separate enum & key namespace from Preview).
ContextKind::Private -> ContextKey::Private(tab_id) (unique per private tab; never shared).
ContextKind::RemoteServer { server_id, proxy } -> ContextKey::RemoteServer(server_id) using canonical ServerKey::as_str() identity (never display name; #[serde(alias = "partition")] kept for wire compatibility).
- Fail closed everywhere (zero silent fallback to
Default):
- Engine refuses empty/whitespace keys (
browser.context.invalid), non-loopback proxies (browser.proxy.invalid), and request_context_create_context / browser_host_create_browser_sync failures (browser.context.unavailable) with an explicit guard forbidding context.is_isolated() && req_ctx.is_none().
- Desktop
App::default_browser_context() always returns RemoteServer for non-sidecar servers (removing #277's fallback to Default when !engine_partitions() so older engines fail closed with browser.partitions.unsupported); isolated pop-ups never inherit into Default.
- Strips
file_roots on all isolated contexts (context.is_isolated()) in both host and engine, and preserves agent_driven across Linux ReopenTabs.
- In-memory lifetime & immediate last-tab teardown:
- All non-
Default contexts use empty cache_path + persist_session_cookies: 0 (0 bytes on disk) plus WebRTC/DoH/QUIC/DNS-prefetch lockdown.
ContextPool::release_tab(tab_id) ref-counts open tabs per ContextKey and immediately removes the entry, closes all connections, deletes in-memory cookies, and drops the CefRequestContext when the last tab closes (retaining RemoteServer proxy configs in remote_proxies until DropContext).
- One creator for all three agents: Exposes
ContextPool::resolve_with_hooks (ContextHooks { resource_filter, exclude_default_cookie_schemes, on_created }) for PREVIEWS #281 and ContextKind::is_isolated() for WS-9 #274.
Verification
scripts/guardrails.ps1: 5/5 passed (0 errors)
cargo clippy -p browser-pane --features engine --no-deps -- -D warnings, cargo check -p browser-pane --no-default-features, cargo check --workspace, scripts/web.ps1 -Check, apps/browser-engine build: all passed with 0 warnings
- Live CEF 156 8×8 isolation matrix (
proof/ws1/context-isolation.md): Opened 8 tabs on the same 127.0.0.1 origin (Default, 2 Preview workspaces sharing a grant name, Artifact reusing that name, 2 RemoteServer identities, 2 concurrent Private tabs); each set a cookie, localStorage entry, CacheStorage bucket, and active intercepting Service Worker (/sw-whoami) -> 0 leaks across all 56 ordered pairs.
- Live last-tab teardown: Closing the last tab of
Preview, Artifact, RemoteServer, and Private and reopening the exact same keys yielded empty cookies, empty localStorage, empty CacheStorage, 0 SW registrations, and swWhoami = "NO_SW".
- Live fail-closed refusals: Empty preview workspace/grant, empty artifact ID, empty remote server ID (
browser.context.invalid), and non-loopback proxy (browser.proxy.invalid) all emitted EngineMsg::Refused with 0 browsers created.
- On-disk byte audit (166 files in
<PROFILE> after shutdown): Default sentinel found on disk; 0 bytes of all 7 isolated sentinels anywhere on disk.
- Proxied
RemoteServer regression check (prove-p3a.ts): proxyChallenges: 1, proxyAuthedHits: 3, userAuthDuringRemote: 0, 0 direct hits on remote target.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…osed, and drop on last tab close
Hardens `apps/browser-engine/src/context.rs` as the single shared `CefRequestContext`
creator across WS-1, WS-9 (`#274`), PREVIEWS (`#281`), and BROWSER-TOOLS (resolving
`notes/review-rd274.md` Finding 5):
- **Partitioned scopes & canonical keys (`ContextKind` / `ContextKey`):**
- `Default` -> global persistent profile (`OPENCODE_BROWSER_PROFILE/Default`).
- `Preview { workspace, grant }` -> `ContextKey::Preview { workspace, grant }` (distinct per
workspace and grant; never shares across workspaces or with artifacts).
- `Artifact { artifact_id }` -> `ContextKey::Artifact(artifact_id)` (separate namespace from
workspace previews).
- `Private` -> `ContextKey::Private(tab_id)` (unique per private tab; never shared).
- `RemoteServer { server_id, proxy }` -> `ContextKey::RemoteServer(server_id)` keyed by
canonical `ServerKey::as_str()` identity (never display name; keeps `#[serde(alias =
"partition")]` for wire compatibility).
- **Fail closed on every path:** Empty keys return `browser.context.invalid`; non-loopback
proxies return `browser.proxy.invalid`; `cef::request_context_create_context` or
`browser_host_create_browser_sync` failure returns `browser.context.unavailable` with an
explicit pre-create guard forbidding `!context.is_default() && req_ctx.is_none()`. On
desktop, `App::default_browser_context()` always returns `RemoteServer` on non-sidecar
servers (never silently falling back to `Default` when an older engine lacks
`Ready.partitions`), and pop-ups from isolated contexts never inherit into `Default`.
- **Ref-counted teardown & zero disk writes:** Every non-`Default` context runs strictly
in memory (`cache_path: ""`, `persist_session_cookies: 0`), disables WebRTC non-proxied
UDP/multiple routes, DoH, QUIC, and DNS prefetching, strips `file_roots`, and drops
immediately when its last tab closes (`ContextPool::release_tab`, closing connections and
wiping cookies/storage/caches/service workers; `RemoteServer` proxy configs remain in
`remote_proxies` until `DropContext`).
- **Shared hooks for PREVIEWS (`#281`) & WS-9 (`#274`):** Adds `ContextHooks`
(`resource_filter`, `exclude_default_cookie_schemes`, `on_created`) on
`ContextPool::resolve_with_hooks` and `ContextKind::is_isolated()`, plus preserves
`agent_driven` across Linux dmabuf `ReopenTabs`.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hona
added a commit
that referenced
this pull request
Nov 20, 2026
…18..UP-122 (#295)
- Fold verified fleet PRs #278, #285, #287, #288, #289, #290, #291, and
#293 (Rune dc8f7f72: #1301, #1302 focus rescue verified Send+Enter -> effort)
into docs/upstream-sync/ledger.{json,md}
- Close UP-062 packaged-default regression (#278), UP-095-UI / UP-100 /
UP-106 / UP-109 / UP-117 (#285, #289), and PRE-08 (#287); reassign
UP-115, UP-116, UP-075 to BROWSER-UI
- Add separate Reviewed column for browser rows tracking retrospective
security reviews on merged PRs (#245, #268, #272, #277, #288, #275, #287,
#285, #289) and pre-merge holds (#274, #280, #281, #283, #286, #292, #294,
and BROWSER-TOOLS PR 3+)
- Audit upstream anomalyco/opencode bfee96a859..2002222d13 (+6 commits:
1 skipped, 5 added: UP-118..UP-122) and refine radar routing
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|