Repository navigation
feat(browser-engine): add isolated oc-preview scheme handler with open-handle confinement - #281
Merged
Merged
Conversation
|
PR test build retired — merged into |
…heme # Conflicts: # crates/browser-pane/src/client.rs # crates/browser-policy/src/lib.rs
Hona
added a commit
that referenced
this pull request
Nov 20, 2026
…osed, and drop on last tab close (#288) 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`.
…usal, broad-root guard, and range bounds
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
…Pool, offload local I/O, and merge dev aaca317
…loud Filter placeholders via NtCreateFile walk, cap per-grant I/O with unwind guard, and harden remote roots
Hona
added a commit
that referenced
this pull request
Nov 20, 2026
…304) - Fold verified merged PRs #280 (WS-9 crates/browser-extensions, confirmed), #281 (PREVIEWS oc-preview:// + ContextPool::is_tab_ready, confirmed third read + merge check), #297 (inline chat video + reply link menu, not reviewed before merge), #299 (WS-1 close_all_connections crash fix), and #300 (Rune eff95e80: #1304 roving-group rescue + #1291 monochrome SMIL animated icons completing UP-069 / WS-6) - Update browser Reviewed column and note #287 eager-attach time_updated regression on UP-095-TOOLS - Audit upstream anomalyco/opencode 2002222d13..fe8def6854 (+19 commits: 7 skipped, 12 added: UP-123..UP-134)
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.
Summary
Lands PREVIEWS PR 1 (
apps/browser-engine+crates/browser-policy+crates/browser-paneprotocol): the isolatedoc-preview://custom scheme handler, per-preview ephemeralCefRequestContextvia WS-1's shared#288ContextPool, parent-handle-relative pre-open walk + open-handle kernel path confinement (including Windows Cloud Filter / OneDrive placeholder support), bounded per-grant off-IO-thread local file streaming, strict CSP /Connection-Allowlist/ verified deferred lockdown prefs, and credential-free async proxy protocol for remote workspace files and artifacts (anomalyco/opencode#63002).Round-2
notes/review-rd281.mdBlockers Closed (Delta overed23e2ca)apps/browser-engine/src/{context,engine,handlers,prompts,preview/{context,handler,mod}}.rs):ContextPool::is_tab_ready(&self, tab_id: u64) -> bool(tracksdefault_tabs; returnsfalsefor any unknown, closed, uninitialized, or failed-pref tab;truefor liveDefaulttabs or initialized + pref-verified +on_initialized-completed isolated tabs) andclear_pending_load(tab_id)(coordinated inORCHESTRATOR-inbox.mdwith WS-1 for#292).generationtoken onResolvedContext/ManagedTab/DeferredOutcome::{Load,Refuse}and prunedready_loadsinrelease_tab.!is_init) ontoabout:blank; gatedHostMsg::{CdpCall,Navigate,Back,Forward,Reload,ContextMenuAction,ClearSite,ClearSiteCache,SiteCookies,SetInspect,HighlightNode,Emulate}andpending_clearsonself.contexts.is_tab_ready(tab_id).PreInitBlockResourceHandlerinIsolatedContextHandler::resource_request_handlerpluscontext_ready: Arc<AtomicBool>checks inTabRequestHandler::{on_before_browse,on_open_urlfrom_tab},TabResourceRequestHandler::{on_before_resource_load,on_resource_redirect},TabLifeSpanHandler::on_before_popup, andPreviewResourceFilter::on_before_resource_load— cancelling EVERY non-about:blanknavigation, subresource, worker, beacon, redirect, or popup beforeon_request_context_initializedfinishes verifying prefs.PreviewSchemeHandlerFactoryregistration intoContextHooks::on_initializedso the scheme handler factory is registered (andPreviewGrant::mark_ready()set) only afterapply_context_prefshas verified all three CEF 156 lockdown prefs (webrtc.ip_handling_policy,net.network_prediction_options,net.quic_allowed).NtCreateFilewalk (apps/browser-engine/src/preview/handle_path.rs):NtCreateFile(OBJECT_ATTRIBUTES.RootDirectory) starting from the verified pinned workspace root handle, eliminating the Windows intermediate-walk check-then-use SMB/NTLMv2 race.FILE_ATTRIBUTE_REPARSE_POINTrejection withGetFileInformationByHandleEx(FileAttributeTagInfo)allow-listing only non-redirecting Windows Cloud Filter placeholder tags (IO_REPARSE_TAG_CLOUD*:(tag & !0x0000_F000) == 0x9000_001Aand legacyIO_REPARSE_TAG_ONEDRIVE:0x8000_0021), strictly refusing bit-29 name surrogates (symlinks, junctions, mount points, WSL symlinks),APPEXECLINK, and every unknown tag.FILE_OPEN_REPARSE_POINTsocldflt.syshydrates/traverses the placeholder, then re-verifiesFILE_TYPE_DISK, directory/non-directory attribute,FileAttributeTagInfotag,GetFinalPathNameByHandleWlocal\\?\<drive>:\containment,preview_allowed, and post-open root pin. (Known residual: for a Cloud Filter placeholder leaf only, a local attacker with write permission inside the workspace could attempt to swap the leaf between the initial tag check and the hydrating re-open; post-open final-path and reparse-tag verification still strictly confines any served bytes.)PreviewIoPoolquota + panic unwind isolation (apps/browser-engine/src/preview/{io_pool,mod,handler}.rs):IoPermitenforcingMAX_GRANT_IO_JOBS = 32inside the 256-slot global queue so one abusive preview tab cannot starve other preview tabs.std::panic::catch_unwindwith anon_paniccallback that marks handler state canceled (recovering cleanly from poisoned mutexes viaunwrap_or_else(|e| e.into_inner())), cancels the CEF open/skip/read callback, and releases theIoPermitwithout terminating worker threads.crates/browser-policy/src/lib.rs):normalize_root_lexto reject\\.\...(device namespace),\??\...(NT object namespace), extended\\?\...unless strictly\\?\<drive>:\...(rejecting\\?\UNC\...,\\?\Volume{...},\\?\GlobalRoot\...), leading///..., internal//(C://Windows,/etc//ssh), drive-relative paths (C:Windows), and non-absolute roots.Round-1
notes/review-rd281.mdBlockers Already Confirmed Closed ated23e2cadata:image/*or own-grantoc-preview://; non-preview tabs disallowoc-preview://favicons.ContextPooladoption: Solerequest_context_create_contextcaller inapps/browser-engine/src/context.rs; canonicalContextKind::{Preview,Artifact}keys; verified CEF 156 lockdown prefs; never falls back toDefault; cleans duplicatetab_id.InitiatorCache+ off-IO-thread I/O: BoundedInitiatorCache(map <= 4096,order <= 8192),req_id != 0, records only allowed same-grant requests; all local open/seek/read off CEF's IO thread.openat(O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC)+ leafO_NONBLOCK | O_NOFOLLOW+ Linux pin without mutablest_ctime.preview_initiator_allowedreturnsfalseonNone/"";on_before_popuprequiresuser_gesture != 0and caps URLs at16_384B;on_before_downloadcancels evenstart_download;TabContextMenuHandlersanitizes URLs & dropssrc_url/SaveImage;TabFileDialogHandlercancels file pickers;TabDialogHandlersanitizesorigin_url;SetTabPolicystripsfile_roots;random_grant_hostfails closed on OS CSPRNG error.PreviewFetch.path, validated singleRange,206total-size*response_length, artifact200-only, remote MIME strictly from extension,total_received <= content_length+ 8 MiB unread backpressure + early-fail & disconnect cleanup.is_safe_workspace_rootrefusesC:\Users,/Users,/home,/var,/private/var, Windows/Unix OS system trees,.., and control chars;preview_allowedapplies Windows rules byroot_is_windows(root).#281confirms): routes all 6 livefile://workspace HTML entry points + remote/api/fs/read/*+ artifacts throughoc-preview://, bans rawfile://unconditionally across app and engine, shows source on older engines lackingReady.preview(neverfile://), avoids double-encodingPreviewFetch.path, excludes previews/artifacts from history/savedTabs/sitePermissions, and refuses hidden/secret entry files for agent requests.Empirical CEF 156.0.26 & Windows
cldflt.sysFindings (proof/previews/pr1-engine-proof.json:ALL_PASS)CdpCall("Runtime.evaluate")+Navigate+ClearSiteCache+Page.navigatein the exact same write burst asOpenTab(local preview)returnedok: false, message: "browser.context.initializing"for bothCdpCallandClearSiteCache, emitted0leaked HTTP hits, and loadedLocalPreviewAcleanly onceon_request_context_initializedverified prefs and registeredPreviewSchemeHandlerFactory.blob:iframe inheritingConnection-Allowlist: (response-origin);webrtc=block(live A/B on CEF 156.0.26):Defaultcontext, no header,blob:iframe running TURN-TCP + STUN UDP):tcpHits: 1, udpHits: 3(both connect).fetch("http://localhost:.../blob-iframe-cross")from ablob:iframe: executed cleanly (loaded: true) and was blocked on BOTHAllowlistOnly(Defaultcontext, ONLYConnection-Allowlistheader, zero prefs) andLocalPreviewA(crossOk: false,blobIframeCrossFetchLeakedHits: 0).RTCPeerConnectionfrom ablob:iframe on BOTHAllowlistOnly(Defaultcontext, header-only, zero prefs) andLocalPreviewA(isolated preview tab):tcpTurnHits: 0, udpHits: 0— Chromium 156 actively inheritswebrtc=blockintoblob:sub-frames at the browser-process Mojo binder layer (No binder found for interface network.mojom.MdnsResponder for the frame/document scope) and immediately terminates the hostile renderer (RESULT_CODE_KILLED_BAD_MESSAGE, reason123) before emitting a single packet.cldapi.dll+cldflt.sys) hydrated & dehydrated placeholder proof (live, scratch sync root, zero OneDrive touched):OpenCodePreviewCloudProof(8b3f52d1-90a4-4e55-b0c1-2d3e4f5a6b7c, zero Explorer nav-pane entry) in scratchC:\tmp\opencode\previews\pr1-proof\cloud_ws:docs:attrs=0x00000410, tag=0x9000601A(IO_REPARSE_TAG_CLOUD_6) -> ALLOWED.docs/index.html:attrs=0x00000420, tag=0x9000601A(IO_REPARSE_TAG_CLOUD_6) -> loaded cleanly ("CloudHydratedOK").docs/dehydrated.txt:attrs=0x00401620, tag=0x9000401A(IO_REPARSE_TAG_CLOUD_4,FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS) -> re-opened withoutFILE_OPEN_REPARSE_POINT, hydrated viacldflt.sysCF_CALLBACK_TYPE_FETCH_DATA(hydrations: 1), returned200"CLOUD_HYDRATED_OK!".docs/junc_outinside the same Cloud Filter directory:attrs=0x00000410, tag=0xA0000003(IO_REPARSE_TAG_MOUNT_POINT) ->juncBlocked: true.finally(CLEANUP unreg=0x80070002 cfCheck=0x80070002 exists=False syncRootManagerKey=False explorerNavPane=False clsid=False).PreviewIoPoolquota (live): Simultaneous 48-read burst on Tab 1 (tab1BurstOk: 35, excess above 32-job cap cancelled cleanly off IO thread) + 8 reads on Tab 20 ->tab20ConcurrentOk: 8/8(zero cross-tab starvation).ALL_PASS):DownloadImagevsResourceRequestHandler: web control2hits vs local & artifact preview0hits.webrtc.ip_handling_policy,net.network_prediction_options,net.quic_allowedall read backSet) +Connection-AllowlistA/B (tcpTurnHits: 0, udpHits: 0, crossOk: false; previewcands: 0, tcpTurnHits: 0, udpHits: 0).206(bytes=10-13/16->"ABCD"), extension-only MIME override (text/plain; charset=utf-8), per-segment encoding (site/a%3Fb%23c.txt), invalidRangenormalized away, artifact206rejected,15/15broad local/remote roots refused (incl.C://Windows,C:Windows,\\?\UNC\...,///etc/ssh/dir,\\.\C:\Windows,\??\C:\Windows),34/34hostile local probes +8/8Web Worker escapes blocked, context menu sanitized +SaveImage0 downloads,file_chooser_blocked: true.fcntl(F_GETPATH)) & Linux (/proc/self/fd+openat) open-handle paths:openat(O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC)intermediate walk +O_NONBLOCK | O_NOFOLLOWleaf +S_IFREG+/proc/self/fd+(dev, ino)pin without mutablest_ctime); not executed live on Linux in this run.openatwalk +fcntl(F_GETPATH)+ immutablest_birthtime/nsecpin; compiled by CIbuild-macosand queued withPROOF-FARMfor headless execution onairviaproof/previews/mac-handle-path-proof.ts(not yet executed live at push time).Build & Guardrail Verification
pwsh scripts/guardrails.ps1: 5/5 passedapps/browser-engine --bins: compiled, 0 warningscargo check --workspace: passed, 0 warningscargo check -p browser-pane --no-default-features: passed, 0 warningspwsh scripts/web.ps1 -Check(wasm32): passed, 0 warningsproof/previews/engine-security-proof.ts->proof/previews/pr1-engine-proof.json:ALL_PASS