Skip to content

fix(security): harden zero-click fetches, SVG/image actions, and remove auth_token from media URLs (A2b) - #383

Merged
Hona merged 4 commits into
devfrom
browser-ui/sec-a2b-images-fetches
Nov 21, 2026
Merged

Hona merged 4 commits into
devfrom
browser-ui/sec-a2b-images-fetches

Conversation

@Hona

@Hona Hona commented Nov 21, 2026

Copy link
Copy Markdown
Member

Summary

Security hardening A2b: zero-click fetches, image context-menu / SVG handling, and removing the auth_token query parameter from /api/fs/read media URLs (parity with official b9a60d9d packages/app/src/runtime/server/api.ts:45-56 fileStreamUrl and workspaces/files/model.tsx:228-241).

  • Zero-click public-network & local-path confinement:
    • crates/browser-policy/src/network.rs: is_public_ipv4 / is_public_ipv6 / is_public_ip / is_public_http_url refusing loopback, RFC 1918 LAN, CGNAT, link-local/IMDS, ULA, .localhost/.local/.internal/.arpa, alternate IPv4 encodings (incl. empty 0x), credentials, and port 0.
    • crates/opencode-platform/src/web_fetch.rs: resolves DNS, validates every returned IP via is_public_ip, refuses redirects onto non-public targets, and bounds response size.
    • crates/session-view/src/images/markdown.rs: gates zero-click web image & favicon fetches on is_public_http_url and refuses raw UNC/device paths before enqueuing.
    • apps/desktop/src/workspace/lifecycle/launch/boot.rs: verifies local markdown image paths through pinned_local_root + verify_local_path before fetching.
    • features/files/src/code_paths.rs: blocks raw UNC and verifies fixed-drive/non-reparse local paths before zero-click existence checks.
  • Image menu & SVG (crates/session-view/src/images/{drag,menu}.rs, crates/opencode-i18n/locales/rune/en.json):
    • Native "Open" label now accurately reflects Reveal in Finder / File Explorer / folder; wasm32 blob open uses an explicit raster-only MIME allow-list (never opening scriptable image/svg+xml in a same-origin blob: tab); Save As preserves .svg for user-confirmed saves while drag-out stays strictly sniffed raster extensions.
  • No auth_token query parameter in media URLs (crates/opencode-kit/src/client/{mod,http,media}.rs, features/files/src/{lib,ops,video}.rs, apps/desktop/src/surfaces/files/reply.rs):
    • Server::stream_url returns None whenever self.auth.is_some() (credentials never appear in URLs, matching official fileStreamUrl).
    • Password-protected remote servers download media strictly via Authorization HTTP headers (zero redirects, 64 MiB cap) into an owner-only TempMediaFile (0o700 dir, handle closed before returning for Windows Media Foundation FILE_SHARE_READ, auto-deleted on drop; off the UI thread in Files panel via AuthVideoDownloads).

Verification

  • scripts/guardrails.ps1: 5/5 passed.
  • Windows cargo check --locked --workspace and scripts/web.ps1 -Check (wasm32-unknown-unknown): both clean (0 warnings).

@Hona
Hona merged commit 7329198 into dev Nov 21, 2026
@Hona
Hona deleted the browser-ui/sec-a2b-images-fetches branch November 21, 2026 04:11
@github-actions

github-actions Bot commented Nov 21, 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.

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