Skip to content

fix(files): require click-to-load for all inline reply videos - #307

Merged
Hona merged 3 commits into
devfrom
browser-ui/sec-a1b-click-to-load-video
Nov 20, 2026
Merged

Hona merged 3 commits into
devfrom
browser-ui/sec-a1b-click-to-load-video

Conversation

@Hona

@Hona Hona commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Makes all inline reply videos click-to-load — no video in an assistant reply ever opens or decodes without an explicit user click (neither inside-workspace nor outside-workspace), keeping cloned-repo bytes out of in-process OS demuxers/decoders (AVURLAsset on macOS, Media Foundation on Windows) until clicked while preserving #297's player UI and controls. http(s) web video links stay ordinary links and open in the embedded browser pane.

What changed vs dev (ae3e9105)

  • Zero auto-load on display (apps/desktop/src/surfaces/files/reply.rs, host.rs, crates/session-view/src/{lib.rs, video.rs, video/transport.rs, timeline/parts.rs}, en.json):
    • Removed auto-load completely (ReplyVideo::Auto removed; reply_video_source returns Option<String> — the real sanitized display path only, with zero disk, network, or Player::new activity on display).
    • Local files (inside or outside workspace; outside strictly on local sessions via app.can_open_in() && !is_remote_session(app)): Display runs only pure lexical safe_local_reveal_path (0 disk/SMB/autofs I/O; consistent native separators on Windows) and renders a compact Play control disclosing the real path before click — middle-truncated on the button (preserving both root/drive prefix and file name), full path in .help(...) hover tooltip, and full path in accessibility .label(...) (never using model-controlled link text).
    • Click-time verification: Clicking Play runs reply::load_video (verify_within_root for local inside-workspace files, /api/fs/read/... for remote inside-workspace files, and verify_local_path + verified.is_file for local outside-workspace files, showing a toast on refusal) and transitions Slot::Starting -> Slot::Active (Player::new + play()), mounting #297's unchanged transport::stage player. Clips::poll drops pending Starting slots on session switch and Clips::view drops mismatched Starting slots.
    • Reference-style Markdown links stay in place (video.rs, timeline/parts.rs): Document reference definitions are appended invisibly to each Markdown slice instead of detaching Play controls to the bottom of the message.
    • http(s) web video links stay ordinary links: Link::Web returns None from reply::video and opens in the embedded browser pane on click (both local and remote-server sessions), gaining browser_policy, remote TunnelProxy, isolated storage, and sandboxed decoders.

Follow-up tracked in Rune's rune-media crate & accepted local-click boundary

  • Follow-up in rune-media (being taken in Rune separately):
    • macOS (crates/rune-media/src/video/macos/asset.rs): set AVURLAssetReferenceRestrictionsKey: AVAssetReferenceRestrictionForbidAll when opening local assets so a clicked local .mov cannot dereference unverified local/autofs files via QuickTime dref/alis references.
    • Windows (crates/rune-media/src/video/windows/mf.rs): drop MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE (and set MF_RESOLUTION_DISABLE_LOCAL_PLUGINS) so a crafted .mp4 cannot fall through to the registered .nsc network stream handler or third-party byte-stream handlers.
  • Check-to-open TOCTOU window: verify_local_path / verify_within_root drops its handle before Rune's worker thread opens the path (and re-opens by path after 3 s idle park), leaving a check-to-open race only for an attacker who already has write access to the target file's parent directory — accepted on an explicit user click once the real path is clearly shown before the click.

Driven Proof (Windows Live + Target Checks)

Case Result
Local session display: in-workspace good.mp4 0 auto-loaded players (autoLoadedCount: 0), 0 opens of workspace\good.mp4 in I/O trace; Play button discloses C:\tmp\...\workspace\good.mp4
Local session click on in-workspace good.mp4 Play button Opens workspace\good.mp4 only after click (inWorkspaceGoodMp4OpensAfterClick: 2) and mounts clip-*
Local session display: outside clip.mp4 ([Spoofed Demo Label]) & long path (> 60 chars) Play button discloses real path (never "Spoofed Demo Label"); long path middle-truncates to · C:\tmp\opencode\browse…26\outside-long-filename-demo.mp4 with full path in tooltip & accessibility label; 0 disk/SMB opens on display
Local session click on outside clip.mp4 vs junction / subst-to-UNC Valid clip.mp4 verifies & transitions to clip-*; junction & subst-to-UNC refuse with toast (Couldn't open), 0 target/SMB opens
Local & remote web video links (http://127.0.0.1:<port>/web-clip.mp4, https://cdn.example.com/demo.mp4) Plain links (0 Play buttons, 0 app-process HTTP fetches); clicking opens the embedded browser pane on both local and remote sessions
Reference-style link ([Ref Clip][v] above TRAILING_PROSE_BELOW_CONTROL) Play control stays inline between link (y=204) and trailing prose (y=274.41) at y=234.41
Remote-server session (127.0.0.2 non-local): outside local path 0 Play buttons / 0 players
  • Captures: proof/browser-ui/sec-a1b/a1b-click-to-load-{dark,light}-1x.png & proof/browser-ui/sec-a1b/results.json (head fc3df8c5).
  • Compile checks: scripts/guardrails.ps1 (5/5), browser-policy aarch64-apple-darwin & x86_64-unknown-linux-gnu, Windows check --workspace, scripts/web.ps1 -Check (1041 files / 48 crates), apps/browser-engine check, build -p opencode-desktop — all 0 errors, 0 warnings.

…or inline reply videos

- `crates/browser-policy/src/remote_url.rs` & `lib.rs`: add `is_public_http_url` (refusing
  credentials, percent/non-ASCII host obfuscation, single-label hosts, local/internal/metadata
  DNS suffixes, alternate IPv4 notations, and all non-globally-routable IPv4/IPv6 ranges
  including loopback, RFC 1918, CGNAT, link-local/IMDS `169.254.0.0/16`, and ULA `fc00::/7` /
  `fd00:ec2::254`) and `sanitized_http_host`.
- `crates/session-view/src/video.rs`, `video/transport.rs`, `lib.rs`: add `ReplyVideo::{Auto,
  OnClick}` and explicit `Slot::{Starting, Active}` state machine in `Clips`; verified
  in-workspace clips keep auto-loading while outside-workspace local clips and `http(s)` URLs
  render a click-to-load Play control under the link and construct `Player` (with `#297`'s
  unchanged player stage and controls) only after user click and host verification.
- `apps/desktop/src/surfaces/files/reply.rs` & `shell/view/session/host.rs`: perform zero
  outside-disk or network I/O on display; verify outside local paths via `verify_local_path`
  and remote-server `http(s)` URLs via `is_public_http_url` on click (reporting refusals via
  toast).
- `crates/opencode-i18n/locales/rune/en.json`: add `rune.video.localFile`,
  `rune.video.playInline`, and `rune.video.remoteBlocked`.
Hona added a commit that referenced this pull request Nov 20, 2026
- Fold security-confirmed merged PRs #292 (6d7a6ed, WS-1 mandatory
  RemoteServer proxy), #294 (ae3e910, BROWSER-UI file-link/click-to-run
  fix with known symlink/junction root limitation), and #274 (5da6474,
  WS-9 engine MV3 extension host, inert without --extension flags)
- Update browser Reviewed column: #301 in rework (#287 eager-attach
  time_updated regression still live on dev), #296/#298/#302/#303/#305/#306
  in rework, #307 open for pre-merge security review
- Audit upstream anomalyco/opencode fe8def6854..4122af0206 (+2 commits:
  1 skipped #65255 core/codemode, 1 added UP-135 #65215 -> WS-8)
…l path on Play control, and keep reference-link controls inline

Per READER-12's review of #307:
- Remove `crates/browser-policy/src/remote_url.rs` (and its exports), `web_video_url` / `Link::Web`
  inline video handling in `apps/desktop/src/surfaces/files/reply.rs`, and `rune.video.remoteBlocked`
  / `rune.video.localFile` strings. `http(s)` video links stay ordinary links and open in the
  embedded browser pane (enforcing `browser_policy`, remote `TunnelProxy`, isolated storage, and
  sandboxed decoders).
- Disclose the real sanitized local path on `ReplyVideo::OnClick { path }` before click: middle-
  truncated on the Play button (preserving both root and filename), full path in `.help(...)`
  tooltip and accessibility `.label(...)` (never using model-controlled link text).
- Gate `Link::Outside` click-to-load strictly on `app.can_open_in() && !is_remote_session(app)` so
  remote-server sessions never offer a local player for server paths.
- Keep reference-style Markdown links' Play controls inline beside their links by appending
  document reference definitions invisibly to each Markdown slice instead of detaching controls to
  the bottom of the message; also drop mismatched `Slot::Starting` entries cleanly.
@Hona Hona changed the title feat(files): click-to-load control and remote-server policy for inline reply videos feat(files): click-to-load inline video for outside-workspace local clips Nov 20, 2026
Hona added a commit that referenced this pull request Nov 20, 2026
…310)

- Update UP-095-UI evidence to reflect that the 4 #294 findings remained
  present from 0.0.0-dev-440 through published 0.0.0-dev-449 (b62e698)
- Refresh open browser PR security-review states (#296 4th read, #301 3rd
  read, #303 2nd read, #307 updated after 1st read, #308 1st read)
…ideo::Auto)

Per READER-12's in-workspace video ruling on dev (Rune eff95e80 with live Windows Media Foundation
and macOS AVFoundation backends):
- Remove `ReplyVideo::Auto` completely; NO video in an assistant reply ever opens or decodes
  without an explicit user click (neither inside-workspace nor outside-workspace).
- On display, `reply::video` performs zero disk or network I/O and returns only the real
  sanitized path shown on the Play control (middle-truncated on the button, full path in tooltip
  and accessibility label; consistent native separators on Windows).
- On click, `reply::load_video` verifies inside-workspace files via `verify_within_root` (or
  remote `/api/fs/read/...`) and outside-workspace local files (local sessions only) via
  `verify_local_path`, then mounts `#297`'s unchanged player and controls.
- `http(s)` web video links stay ordinary links that open in the embedded browser pane.
@Hona Hona changed the title feat(files): click-to-load inline video for outside-workspace local clips fix(files): require click-to-load for all inline reply videos Nov 20, 2026
@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 merged commit a1e7d0d into dev Nov 20, 2026
7 checks passed
@Hona
Hona deleted the browser-ui/sec-a1b-click-to-load-video branch November 20, 2026 20:27
Hona added a commit that referenced this pull request Nov 20, 2026
Hona added a commit that referenced this pull request Nov 20, 2026
…P-143 (#318)

- Fold confirmed merged PRs #307 (a1e7d0d, click-to-load reply videos),
  #306 (b5167f7, atomic agent_driven), #301 (6522f11, routed-session
  attach + recency closing #287 regression), #296 (95cb36a, legacy
  rune_mcp suppression + Half::is_builtin + check_cdp), #303 (6fb05ce,
  oc-preview:// app routing + raw file:// ban completing UP-095-PREVIEWS),
  and #316 (6e98fc2, Rune 7a707454 / #1307 strict local video opening)
- Add missing browser follow-up rows UP-095-3P-CONTRACT (#296 narrow
  third-party plugin browser contract gap) and UP-095-PROMPT-GATE
  (new-session-start-only prompt gate split from #302)
- Record #302 split (tunnel vs gate), #314 masking stream paused pending
  owner decision on agent-tab contexts, and updated browser Reviewed entries
- Audit upstream anomalyco/opencode 4122af0206..b9a60d9d07 (+11 commits:
  3 skipped, 8 added UP-136..UP-143)
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