Skip to content

feat(browser): native 500 ms guarded app-link review bar and confirmed OS scheme handoff (PR B) - #315

Merged
Hona merged 12 commits into
devfrom
browser-ui/sec-a2a-links-schemes
Nov 21, 2026
Merged

Hona merged 12 commits into
devfrom
browser-ui/sec-a2a-links-schemes

Conversation

@Hona

@Hona Hona commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

PR B of the #315 split (confinement + raw-route hardening already merged as PR A in #338): native 500 ms guarded app-link review bar (surfaces/browser/prompts/app_link.rs, surfaces/browser/links.rs), page-origin EngineMsg::AppLinkBlocked forwarding (apps/browser-engine), and confirmed OS app-scheme launch (features/open-in), closing all 3 READER-12 round-3 blockers.

Fixes for READER-12 round-3 blockers

  1. Zero browser tabs open & mid-load tabs (links.rs:sync_app_link_reviews): tracks saw_settled (initialized from !tab.loading). Conversation reviews no longer vanish on initial about:blank or in-flight tab loading (matching official b9a60d9d pane.ts:470-481 + chromium.ts:886-890, which clear only on committed navigation); settled navigations still clear the bar.
  2. 500 ms guard enforced on pointerdown, not release (prompts/app_link.rs, links.rs:note_app_link_pointer): records action_pressed_at / dismiss_pressed_at at Phase::Down only when visible_since has already elapsed 500 ms (matching official activation-delay.ts:13-53). A press begun before 500 ms and released after 500 ms never activates; keyboard activation checks visible_since with non-repeat enforced by Rune focus.rs:817,827.
  3. Official-parity & hardening:
    • Window viewport clipping in fits() (links.rs:observe_app_link_window_rect, shell/view/mod.rs, panels.rs): checks both text-in-box fit and full visibility inside the root window rect (re-evaluated live on resize), plus .clip_soft(0.0) on panel body.
    • 60 s TTL label flip (links.rs:observe_app_link_review_layout): arms tx.wake_after for expires_at so an idle bar flips from Open to Copy link at 60 s.
    • Host-side document_input for page-only editor schemes (crates/browser-pane/src/{prompts/mod.rs,surface.rs}, browser-policy::is_page_only_app_scheme): records real user pointer/key input to the current document (cleared on nav/reload/document change/context switch, matching official chromium.ts:377-425, 871-969 & refusal-notice.ts:52-54) and downgrades unattended page-origin vscode:/cursor:/zed:/jetbrains: links to Copy; page-origin mailto: enforces the 200-char cap.
    • Win32_System_Registry kept with comment in features/open-in/Cargo.toml because windows-sys gates SHELLEXECUTEINFOW (hkeyClass: HKEY) behind it.
    • ENGINE_REVISION not bumped: dev is already revision 3 while published stable.json is 156.0.26-2.

Verification

  • scripts/guardrails.ps1: 5/5 passed (all touched files within hard ceilings).
  • Windows cargo check --locked --workspace, cargo build --manifest-path apps/browser-engine/Cargo.toml --bins, and scripts/web.ps1 -Check: all clean.
  • Live non-mock CEF proofs (run-proof-prb.ts): verified Blocker 1a (0 browser tabs open, review bar survives about:blank load), Blocker 1b (mid-load /slow tab, review bar survives), and Blocker 2 (early pointerdown at +150 ms held 650 ms blocked with 0 opens; post-500 ms press opened once).

…-path links, open_file, save_download, and macOS volume case checks (A2a)

Splits Security PR A2 by surface (A2a: links, OS schemes, Open-in, plugin/app path guards;
A2b: images, zero-click fetches, remote media auth; A2c: terminal OSC 8 dialog):
- `crates/browser-policy/src/app_links.rs` & `plugins/browser/refusal.luau`: percent-decode query
  keys (and split on `&`/`;`, failing closed on malformed `%`/controls) in `mailto_has_attachment`
  for `attach|attachment|attachments|file|filename|filepath|body-file` (for both conversation and
  page sources); reject BOM/zero-width chars; add explicit `is_safe_os_external_url` allow-list.
- `crates/browser-policy/src/lib.rs`: reject `\` before `/` in `destination_origin` /
  `is_http_with_credentials` (closing `http://public.example.com\@127.0.0.1/`).
- `crates/browser-policy/src/local_fs/unix.rs`: honor macOS per-volume case sensitivity via
  `fpathconf(fd, _PC_CASE_SENSITIVE) == 0` in `verify_within_root` (from #294 Mac run).
- `features/open-in/src/{lib,windows}.rs`, `apps/desktop/src/workspace/system/open_in.rs`,
  `features/office/src/sheet/input.rs`, `status_toast.rs`, `requests.rs`: enforce
  `is_safe_os_external_url` at every OS handoff (`open_external`, spreadsheet links, toast
  `openUrl`, `System:OpenExternal`); drop `.cmd`/`.bat` shim fallback in `windows.rs::resolve`;
  launch Windows Terminal via `wt -w new -d .` with `.current_dir(&dir)`; gate
  `HARNESS_OPEN_EXTERNAL_LOG` behind `debug_assertions`.
- `apps/desktop/src/surfaces/browser/links.rs`: stop cross-session `focused_tab_id` fallback in
  `queue_browser_app_link_review`.
- `crates/session-view/src/style.rs`: ignore attacker-authored `opencode-code-path:` Markdown
  links (and never suppress their hover tooltip) unless verified in `code_links`.
- `plugins/file/init.luau` & `tool_open.rs`: block backslash `..` traversal and UNC/device paths
  in `open_file` MCP tool / `Workspace:Relative`.
- `plugin_host/services/{ui,diag}.rs` & `opencode-kit/src/client/downloads.rs`: guard
  `Links:Exists` and heap-snapshot metadata via `verify_local_path`; confine `save_download`
  strictly to a single safe basename inside Downloads.
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

@Hona

Hona commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Round-2 fixes pushed at 5b541369a9bd1e9ec3895e002ac34b33475a1dee closing all 4 READER-12 findings:

  1. open_file / tool_open::relative & Workspace:{Relative,OpenFile}: normalises separators and strips leading ./ / .\ repeatedly before checking (without .trim() masking trailing spaces), refuses :, absolute/drive-relative paths, UNC/device prefixes, .. in either separator, trailing dots/spaces in any component, and Windows device stems, and requires browser_policy::verify_within_root as final authority on local live servers (tool_open.rs, plugins/file/init.luau, services/net.rs, native/files.rs).
  2. 23 guarded app schemes preserved with strict unconfirmed allow-list: direct/unconfirmed open_external and plugin System:OpenExternal keep is_safe_os_external_url; confirmed "Open" on the 500 ms review bar uses a single-use host-minted token (Browser:ConfirmAppLinkReview) bound to the exact (tab_id, url, source), reachable only from the built-in browser UI during a live UI gesture (cx::in_ui_gesture()), gated on >= 500 ms host-side elapsed, active session match, and is_confirmed_app_scheme_url (APPS + page-only PAGE_ONLY via EngineMsg::AppLinkBlocked); browser.chrome.showExternalNotice is forced copy-only.
  3. Remaining raw OS URL routes: SettingsHost::open_external (apps/desktop/src/dialogs/settings/mod.rs) and Linux updater external_install (features/updater/src/linux.rs) now enforce browser_policy::is_safe_os_external_url (plus external_url_allowed_for_session in Settings).
  4. mailto: RFC 6068 allow-list & conversation review bar: replaced the 7-key blocklist with a strict RFC 6068 allow-list (to, cc, bcc, subject, body only) and routed conversation mailto: through the 500 ms review bar displaying decoded To:, Cc:, and Bcc: lines before confirmation. Also updated the stale comment at features/open-in/src/windows.rs:9.

Live proof (proof/browser-ui/sec-a2a/results.json): 19/19 open_file bypass forms refused (incl. real NTFS junction escape) & 4/4 valid workspace paths allowed; all 23 guarded app schemes (18 conversation APPS + 5 page-clicked PAGE_ONLY via real opencode-browser-engine.exe) launch only via the 500 ms review bar with 0 launches from 3P plugin / non-gesture JS / conversation PAGE_ONLY; hostile Console URLs blocked in SettingsHost::open_external; conversation mailto: shows To/Cc/Bcc before confirm, ignores early clicks, and refuses disallowed query keys.

@Hona

Hona commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Round-3 fixes + merge of origin/dev 6e98fc2b (#303 + #316 Rune 7a707454) pushed at 9e980a066b022ce71e2b91d9705267d55550b590 (previous head 5b541369 passed 6/6 CI checks).

Official parity (anomalyco/opencode origin/dev b9a60d9d078d87bfb90f039e431090508f88ac02) & stricter ours.md rules

  • Direct mailto: open on reply click (apps/desktop/src/surfaces/browser/links.rs): matches official packages/app/src/runtime/plugin/app-links.ts:22-29 & render.tsx:212 (no browser review bar; the OS mail client compose window displays every recipient).
    • ours.md (stricter than official): mailto: enforces an RFC 6068 query-key allow-list (to, cc, bcc, subject, body only; anything else copies only) instead of official's two-key attach/attachment blocklist, and requires strict RFC 3986 URI characters with no exemption.
  • Strict RFC 3986 URI character confinement + OS association launch (crates/browser-policy/src/app_links.rs, features/open-in/src/{lib.rs,windows.rs}, plugins/browser/refusal.luau):
    • ours.md (stricter than official): refuses ", whitespace, \, < > ^ { | }, controls, bidi, non-ASCII, and malformed %XX/%00–%1F/%7F before offering any review bar or OS launch (mailto:` included).
    • Windows launches confirmed app schemes via ShellExecuteExW (SEE_MASK_FLAG_NO_UI, lpVerb = "open", no command-line splicing by us — classic %1 substitution into "%1" cannot break out of quotes or inject flags when ", \, and whitespace are rejected; MSIX/UWP DelegateExecute handlers work directly). macOS uses /usr/bin/open -- <uri>; Linux uses xdg-open <uri> as a single argv element.
  • Native host-owned app-link review bar (apps/desktop/src/surfaces/browser/{links.rs,prompts/app_link.rs}, apps/desktop/src/plugin_host/ui/panels.rs, apps/desktop/src/shell/view/mod.rs):
    • Matches official packages/gui-plugins/src/browser/{refusal-notice.ts:3-36,44-55, refusal-bar.tsx:11-163, notice-actions.ts:16-50, chromium.ts:582}: 128-bit CSPRNG single-use token (getrandom::fill) expiring after 60 s (downgrading to Copy), 500 ms activation delay starting only once the bar is visible and stationary in the focused window (El::on_drawn_layout_tx), teardown on tab close / navigation / tab switch / session switch / window blur, and live fits() check (refusal-bar.tsx:18-63 via .wrap_anywhere() + viewport max_h(80.0) vs target text rect check downgrading clipped URLs to Copy-only).
    • Mounted natively by the host above the built-in browser panel gated on app.plugins.is_builtin_plugin(ctx.plugin) with .on_press_tx directly on the native Open/Copy button (never hover, no Luau ConfirmAppLinkReview API, never reachable from plugins or MCP tools; TakeAppLinkReview returns nil; browser.chrome.showExternalNotice stays copy-only).
  • Isolated tabs never emit AppLinkBlocked (apps/browser-engine/src/handlers.rs:793,913, apps/desktop/src/surfaces/browser/links.rs):
    • ours.md (stricter than official): requires !self.ext_policy.isolated in browser-engine AND ContextKind::Default + !agent_driven + preview.is_none() on desktop so remote-server/private/preview tabs can never raise local editor scheme prompts.

#303 conflict resolutions (origin/dev 6fb05ce1)

  1. apps/desktop/src/plugin_host/native/files.rs: runs #315's tool_open::relative + local verify_within_root workspace confinement first, then #303's is_builtin/in_tool cross-session guard and resolve_workspace_file_target preview routing.
  2. apps/desktop/src/surfaces/browser/mod.rs: keeps both #303's preview_errors/preview_bindings/next_preview_gen + revoke_preview_binding and #315's host-owned active_app_reviews + poll_app_link_reviews() (file stays at 795 lines <= 800).

Live proofs (proof/browser-ui/sec-a2a/{results-r3,results}.json)

  • Registered scratch Windows handler HKCU\Software\Classes\rune-probe (standin.exe "%1"), verified live via Start-Process, then proved ", \, space, and rune-probe: URIs are refused before any bar with 0 handler hits (registry key deleted in finally and verified gone).
  • Direct mailto: opens on click for valid RFC 6068 keys, copies on disallowed keys (attachment-url, send-now), and refuses malformed % / " / space.
  • fits() live probe at 780x800: 199-char slack:// wrapped to 274x96 inside 282x80 viewport -> downgraded to "Copy link" with 0 OS launches.
  • Early click (<500 ms) & hover ignored, real click after 500 ms launches once, tab switch/navigation kills bar, Browser.ConfirmAppLinkReview absent from Luau.
  • Real opencode-browser-engine.exe: ContextKind::Default emits app_link_blocked for vscode://, isolated ContextKind::Private emits 0 app_link_blocked (browser.address.web).
  • Re-verified all 23 guarded schemes (18 conversation APPS + 5 page-clicked PAGE_ONLY), 19/19 open_file attacks refused (incl. NTFS junction), and hostile Settings Console URLs blocked.

Hona added 6 commits November 21, 2026 12:12
…ks-schemes

# Conflicts:
#	apps/desktop/src/plugin_host/native/browser.rs
#	crates/browser-policy/src/app_links.rs
#	features/open-in/src/lib.rs
…ms guard, live window viewport fits(), 60 s TTL wake, and host document_input
…ks-schemes

# Conflicts:
#	apps/desktop/src/plugin_host/native/browser.rs
#	crates/browser-pane/src/prompts/mod.rs
…ks-schemes

# Conflicts:
#	apps/desktop/src/plugin_host/native/browser.rs
#	apps/desktop/src/plugin_host/native/browser/chrome.rs
#	apps/desktop/src/surfaces/browser/mod.rs
@Hona Hona changed the title fix(browser-policy,open-in): harden mailto/OS-scheme allow-list, code-path links, open_file, save_download, and macOS volume case (A2a) feat(browser): native 500 ms guarded app-link review bar and confirmed OS scheme handoff (PR B) Nov 21, 2026
@Hona
Hona merged commit 5c8fb97 into dev Nov 21, 2026
3 checks passed
@Hona
Hona deleted the browser-ui/sec-a2a-links-schemes branch November 21, 2026 03:58
Hona added a commit that referenced this pull request Nov 21, 2026
…ve auth_token from media URLs (A2b) (#383)

* wip(a2b): save partial A2b edits while finishing #315 round 3

* fix(security): harden zero-click fetches, SVG/image actions, and remove auth_token query param from remote video URLs (A2b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant