Repository navigation
fix(files): stop executing outside-workspace file links and block UNC paths before disk access - #294
Merged
Merged
Conversation
… paths before disk access
Confinement fix for the live outside-workspace file link RCE and UNC NTLMv2 leak
(`review-rd-tools.md` Finding 1, present since `e2b712c8` and in published `0.0.0-dev-440` `efc20a22`):
- **Policy (`crates/browser-policy/src/local_path.rs`):**
- Add pure string-level `is_unc_or_device_path`, `is_raw_unc_href`, `safe_local_reveal_path`,
and `is_macos_bundle_path` rejecting UNC/SMB shares (`\\server\…`, `//server/…`,
`file://server/…`), Win32/NT device namespaces (`\\?\…`, `\\.\…`, `\??\…`), drive-relative
paths, NTFS alternate data streams, reserved device names, quotes, controls, bidi overrides,
and `..` traversal BEFORE any filesystem call (`exists`, `metadata`, `canonicalize`).
- **Never execute outside-workspace links (`features/files/src/{links,host}.rs`,
`features/open-in/src/{lib,windows}.rs`, `apps/desktop/src/{workspace/system/open_in,surfaces/files/mod}.rs`):**
- Remove `open_default` / `open_in_default` completely (`links.rs` was the sole caller).
- Refuse raw UNC hrefs BEFORE `classify`, `plugin_open_link`, or filesystem touch -> toast naming path.
- Route non-UNC outside links (and Draft `Link::Inside`) at most to file-manager reveal
(`open_in_reveal_abs` -> `reveal_local`) on verified local fixed drives only.
- On Windows (`features/open-in/src/windows.rs::reveal`): verify `GetDriveTypeW == DRIVE_FIXED`
BEFORE `Path::exists()`, select via binary PIDL `SHOpenFolderAndSelectItems`, and remove the
command-line `explorer.exe /select,"..."` fallback.
- On macOS/Linux: validate `safe_local_reveal_path` BEFORE `Path::exists()`; always pass
`/usr/bin/open -R -- <path>` on macOS and parent directory to `xdg-open` on Linux.
- **Harden other OS-reveal entry points (`apps/desktop/src/plugin_host/bridge/requests.rs`,
`apps/desktop/src/shell/chrome/status_toast.rs`, `apps/desktop/src/shell/view/location_card.rs`,
`crates/opencode-plugin-runtime/src/reveal.rs`):**
- Route `Request::Reveal` (`System:Reveal`) and toast Reveal through `open_in::reveal_abs`.
- Guard `location_card::reveal` and `opencode_plugin_runtime::reveal` with `safe_local_reveal_path`
+ directory/bundle checks so bare `explorer.exe <path>` / `/usr/bin/open <path>` never executes files.
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
|
PR test build retired — merged into |
…ndle launch, and local-path NTLMv2 leaks Addresses all 6 blockers from the independent security review of #294: - Timeline/Markdown image drag & Open (`crates/session-view/src/images/{drag,menu}.rs`, `apps/desktop/src/shell/view/session/host.rs`): allow-list content-sniffed raster extensions only (never keep URL/attachment extension); never write non-raster bytes into opencode-drag; remove bare explorer/open/xdg-open from open_with_system/reveal_with_system and route through shared safe reveal. - Windows Terminal & Open-in CLI audit (`features/open-in/src/{windows,lib}.rs`): refuse `;` in folder paths for wt.exe; validate all targets via `browser_policy::verify_local_path` before launching editors/terminals; select CLSID-suffixed folders safely in parent. - macOS bundle launch (`features/open-in/src/lib.rs`, `location_card.rs`, `local_path.rs`): route Finder opens through `/usr/bin/open -R --` only; never pass symlinks or bundles (expanded suffix list + Info.plist + kHasBundle Finder flag) to bare `/usr/bin/open`. - Shared authoritative OS local-path verifier (`crates/browser-policy/src/local_fs.rs`): `QueryDosDeviceW` subst-to-UNC & network-redirector guard + `GetDriveTypeW == DRIVE_FIXED` + component-wise `FILE_FLAG_OPEN_REPARSE_POINT` walk + `GetFinalPathNameByHandleW` on Windows; autofs prefix block + `openat(O_NOFOLLOW)` + `fstatfs` (`MNT_LOCAL` on macOS, non-network/ non-autofs magic on Linux); `(parent_pidl, 1, &child_pidl, 0)` `SHOpenFolderAndSelectItems` with paired `CoUninitialize`. Wired ahead of every disk touch in `open-in`, `browser-policy` (`path_within_root`, `is_safe_workspace_root`), `files/src/ops.rs` (local video), `location_card`, `home/projects.rs`, `settings/pages/project.rs`, `opencode-plugin-runtime`, and `session-view/src/images/menu.rs`. - Complete UNC/device string filters (`crates/browser-policy/src/local_path.rs`, `features/files/src/code_paths.rs`): catch `file:///\\...`, `file://localhost/\\...`, percent-encoded `%5c`/`%2f` UNC forms, mixed `\??/` & `/??\`, control/bidi/BOM prefixes, and `opencode-code-path:` links ahead of `plugin_open_link`. - Unix regressions: scope `:` and DOS device stem rejections to Windows; add `can_reveal_outside` so Linux outside-workspace links reveal parent directories cleanly.
… local-path confinement Merges origin/dev (5fed7fc, including #297 918d24f) into browser-ui/sec-a1-file-links: - apps/desktop/src/surfaces/files/reply.rs: reject raw UNC hrefs in target(), replace std::fs::metadata(&path) with browser_policy::verify_local_path(&path) before building the right-click menu, remove OS open_default ("Open file") for outside-workspace files (outside files offer safe Reveal only; inside-workspace files open in the built-in viewer), and guard local video paths with verify_local_path / verify_within_root. - features/files/src/{ops,video}.rs: route local video playback through browser_policy::verify_within_root before handing a local path to rune::Player. - apps/desktop/src/shell/view/session/host.rs & crates/session-view/Cargo.toml: preserve both sides' TimelineHost methods and dependencies.
…e reparse-tag policy
…ick web/outside reply video auto-load - `features/files/src/video.rs`: on native local servers (or with no server), return `browser_policy::verify_within_root` directly with no fallback to `/api/fs/read/...`, so a workspace symlink or junction cannot bypass confinement via the local server. - `features/files/src/ops.rs`: when `video::source` rejects a video path, return without falling through to `read_file`. - `apps/desktop/src/surfaces/files/reply.rs`: confine `reply::video` auto-load on display to verified regular files inside the session workspace (`Link::Inside`); `Link::Web` (`http(s)`) and `Link::Outside` render as plain links until click-to-load and remote-server address policy land in a follow-up PR.
…d/WOF/Dedup), reuse Unix root fd, and guard multi-dot DOS device names - `crates/browser-policy/src/local_path.rs` & `lib.rs`: add shared `is_allowed_local_reparse_tag` rejecting all name-surrogate tags (bit 29) and unknown tags while allow-listing only non-redirecting local tags (`IO_REPARSE_TAG_CLOUD*`, `IO_REPARSE_TAG_ONEDRIVE`, `IO_REPARSE_TAG_WOF`, `IO_REPARSE_TAG_DEDUP`). - `crates/browser-policy/src/local_fs.rs` & `apps/browser-engine/src/preview/handle_path.rs`: wire both Windows handle walkers to `browser_policy::is_allowed_local_reparse_tag` via `GetFileInformationByHandleEx(FileAttributeTagInfo)` so Windows 11 OneDrive Known Folder Move (`Desktop`/`Documents`/workspaces) and WOF/Dedup files work while symlinks, junctions, mount points, and `APPEXECLINK` remain refused. - `crates/browser-policy/src/local_fs.rs`: reuse the verified `OwnedFd` from `verify_path_open` inside Unix `verify_within_root` instead of re-opening `root` by path without `O_NOFOLLOW`. - `crates/session-view/src/images/drag.rs`: pass the first dot-delimited segment of the sanitized stem to `is_windows_device_name` so multi-dot names such as `CON.foo.png` map to `image.png`.
…e previews and resolve symlinked local workspace roots once
- `crates/browser-policy/src/workspace_root.rs` & `lib.rs`: restore `is_safe_workspace_root`
to a pure lexical check (`normalize_root_lex`, `is_broad_root_lex`, `is_home_broad_lex`)
so cross-OS remote workspace roots (e.g. remote Linux `/remote/work` evaluated on Windows)
and engine `oc-preview://` callers are unaffected. Add `is_safe_local_workspace_root` for
known-local callers (`apps/desktop/src/surfaces/browser/mod.rs`, `path_within_root`).
- `crates/browser-policy/src/local_fs/{mod,windows,unix}.rs`: split `local_fs` by platform
and add `resolve_local_root`, resolving a local symlink/junction workspace alias once up
front (`FSCTL_GET_REPARSE_POINT` on Windows, `openat(O_NOFOLLOW)` + `readlinkat` on Unix,
refusing UNC/mapped/autofs targets before following) so workspaces opened via a symlinked
alias work while inner workspace symlinks/junctions and aliases to broad/system folders
stay refused.
- `crates/browser-policy/src/local_path.rs`: document why `IO_REPARSE_TAG_CLOUD*`,
`IO_REPARSE_TAG_ONEDRIVE`, `IO_REPARSE_TAG_WOF`, and `IO_REPARSE_TAG_DEDUP` are
non-redirecting and that WIM overlays and NTFS dedup chunk stores require Administrator.
…-up, gate engine safe_roots, and fold macOS home-root case
- Move symlinked/junction-aliased local workspace root resolution (`resolve_local_root`,
`resolve_root`, `resolve_root_open`, `read_reparse_target`, `resolve_reparse_hop`,
`readlink_at`, `join_unix_symlink`, and `Win32_System_{IO,Ioctl}`) out to follow-up
branch `browser-ui/followup-alias-root`: local workspace roots that are themselves a
symlink or junction fail closed via `verify_local_path` / `verify_within_root`.
- `apps/browser-engine/src/engine.rs`: route `safe_roots` through
`browser_policy::is_safe_local_workspace_root`.
- `crates/browser-policy/src/workspace_root.rs`: compare home/system suffixes
case-insensitively on macOS as well as Windows (`cfg!(any(windows, target_os = "macos"))`).
Hona
added a commit
that referenced
this pull request
Nov 20, 2026
…eparse policy and unconditional file:// ban
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)
Hona
added a commit
that referenced
this pull request
Nov 20, 2026
Hona
added a commit
that referenced
this pull request
Nov 21, 2026
…d OS scheme handoff (PR B) (#315) * fix(browser-policy,open-in): harden mailto/OS-scheme allow-list, code-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. * fix(browser,open-in,settings,updater): close A2a review findings (open_file, 23 confirmed app schemes, settings/updater routes, mailto allow-list) * chore(desktop): gate native-only app-link review items for wasm32 builds * fix(browser): use wrap_anywhere for app-link review bar target fits() check * fix(browser): fix zero-tab/mid-load review survival, pointerdown 500 ms guard, live window viewport fits(), 60 s TTL wake, and host document_input * style(browser): keep touched files within arch-check and file-size ceilings
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.
What was wrong (in published
0.0.0-dev-440efc20a22)Four local execution and credential-leak issues were present in the published
0.0.0-dev-440build (efc20a22, 19 Nov):features/files/src/links.rs:380, sincee2b712c8, 1 Nov): Clicking a chat Markdown or terminal link outside the session folder calledPath::exists()(initiating an outbound Windows SMB handshake and leaking NTLMv2 hashes on UNC paths) and thenopen_in_default(explorer.exe <path>//usr/bin/open <path>), running.bat/.cmd/.lnk/.exeon one click.crates/session-view/src/images/drag.rs:102,121since067685b5, 7 Nov;menu.rs:121-129sincef3f8d1fd, 8 Nov): Non-PNG/JPEG/GIF/WebP images (e.g. BMP, SVG, ICO, AVIF) kept the attacker-supplied URL/attachment extension (.bat/.hta/.cmd) in%TEMP%\opencode-drag\, and right-click Open ran bareexplorer//usr/bin/open/xdg-open.;injection (features/open-in/src/windows.rs:41, sincef1faf1c8, 12 Nov): Passing an unescaped repository folder name containing;towt -w new -d <dir>letwt.exesplit subcommands even inside quoted arguments.features/open-in/src/lib.rs:155since2e854fe5, 30 Oct;apps/desktop/src/shell/view/location_card.rs:329sincecd697837, 8 Nov): Bare/usr/bin/open <path>(without-R --or symlink/bundle checks) could launch a.appor unlisted bundle directory.What changes (by area)
1. Shared lexical & OS local-path verifier (
crates/browser-policy/src/{local_path.rs, local_fs/*, workspace_root.rs, lib.rs},apps/browser-engine/src/preview/handle_path.rs)is_raw_unc_href,is_unc_or_device_path, andsafe_local_reveal_pathreject UNC/SMB (\\,//,file://host/...,file:///\\...,file://localhost/\\..., percent-encoded%5c/%2fUNC forms, mixed\??/and/??\, WebDAV), Win32/NT device namespaces (\\?\,\\.\,\??\), drive-relative paths, NTFS alternate data streams, control/bidi/BOM prefixes,.., and Unix autofs prefixes (/net,/Network,/misc,/afs,/run/user/*/gvfs).:and Windows DOS device stems (con,aux,nul, etc.) are scoped to Windows paths so valid Unix filenames stay intact.is_allowed_local_reparse_tag): Rejects every name-surrogate/redirecting tag (bit 29: symlinks0xA000_000C, junctions/mount points0xA000_0003, WSL symlinks0xA000_001D, global reparse0xA000_0019),APPEXECLINK, and unknown tags; allow-lists only non-redirecting local tags (IO_REPARSE_TAG_CLOUD*/ legacyIO_REPARSE_TAG_ONEDRIVEfor Windows 11 OneDrive Known Folder Move and Cloud Filter folders,IO_REPARSE_TAG_WOFwhere unprivilegedWOF_PROVIDER_FILEdecompresses only the file's own stream and WIM overlays require Administrator, andIO_REPARSE_TAG_DEDUPwhose volumeChunkStorerequires Administrator). Wired identically into bothcrates/browser-policy/src/local_fsandapps/browser-engine/src/preview/handle_path.rs.workspace_root.rs,apps/desktop/src/surfaces/browser/mod.rs,apps/browser-engine/src/engine.rs):is_safe_workspace_rootremains strictly lexical (no disk/network I/O) so cross-OS remote workspace roots (e.g. remote Linux/remote/workevaluated on Windows) andoc-preview://callers are unaffected. Known-local callers (browser_file_roots, enginesafe_roots,path_within_root) useis_safe_local_workspace_root, which verifies the local root fail-closed viaverify_local_pathand compares home/system suffixes case-insensitively on both Windows and macOS (cfg!(any(windows, target_os = "macos"))).verify_local_path,verify_within_root,is_macos_bundle,reveal_in_file_manager):QueryDosDeviceW(refusingsubst-to-UNC, network redirectors, and recursivesubst-to-junction chains) ->GetDriveTypeW == DRIVE_FIXED-> component-wiseFILE_FLAG_OPEN_REPARSE_POINTwalk inspectingGetFileInformationByHandleEx(FileAttributeTagInfo)->GetFinalPathNameByHandleWconfirming local\\?\<drive>:\.openat(..., O_NOFOLLOW)from/->fstatfsverifyingMNT_LOCALon macOS and non-network/non-autofs magic on Linux;verify_within_rootreuses the verified rootOwnedFddirectly instead of re-opening by path. macOS bundle detection covers an expanded package suffix list,Info.plist, and thekHasBundleFinder flag.2. File links, reveal & Open-in (
features/files,features/open-in,apps/desktop,features/settings,crates/opencode-plugin-runtime)open_default/open_in_default. Outside-workspace chat/terminal links (and Draft links) at most reveal the item in the file manager on a verified local fixed drive (including Linux parent-directory reveal viacan_reveal_outside).opencode-code-path:UNC links are rejected ahead ofplugin_open_link.(parent_pidl, 1, &child_pidl, 0)withSHOpenFolderAndSelectItemsand pairedCoUninitialize(noexplorer.exe /select,"..."fallback); macOS uses/usr/bin/open -R --; Linux usesxdg-openon the directory or parent directory.Win::{open,reveal},Mac::{open,reveal},open_app_as,open_at,drag_item,System:Reveal, toast Reveal,location_card::reveal(removing post-refusalPath::exists()inhome/projects.rsandsettings/pages/project.rs),opencode_plugin_runtime::reveal,browser-policy::{path_within_root,is_safe_workspace_root}, and local video playback (features/files/src/{ops,video}.rs, with no fail-open fallback to/api/fs/read/...whenverify_within_rootrejects a local symlink/junction).wt.exerefuses folder names containing;; CLSID-suffixed folders and macOS symlinks/bundles never reach non--RExplorer or/usr/bin/open.3. Timeline & Markdown images (
crates/session-view/src/images/{drag,menu}.rs,apps/desktop/src/shell/view/session/host.rs)drag::file_nameallow-lists only content-sniffed raster extensions (png,jpg,gif,webp,bmp,ico,avif), never falls back to URL/attachment extensions, and checks the first dot-delimited segment againstis_windows_device_name(soCON.foo.pngbecomesimage.png). Non-raster bytes (such as SVG served as.hta) are never written toopencode-drag.explorer//usr/bin/open/xdg-openfromopen_with_systemandreveal_with_system; both route through shared safe reveal.4. Reconciling #297 (
apps/desktop/src/surfaces/files/reply.rs,features/files/src/{ops,video}.rs)918d24f9) added (a) a right-click context menu on assistant reply links that ran synchronousstd::fs::metadatabefore opening the menu and wired Open file tocrate::open_in::open_default, and (b) an inline reply video player that passed local paths and directhttp(s)URLs torune::Player::newon display.dev(5fed7fcd, then5d50c6f7) preserves Play videos inline in chat and add browser and Finder link actions #297's web-link menu, verified plain-directory Explorer/Finder actions, inside-workspace Open file, and inline player UI for verified workspace clips while:reply::targetand replacingstd::fs::metadatawithbrowser_policy::verify_local_pathbefore showing the menu;video::sourceon native local servers strictly tobrowser_policy::verify_within_root(no fail-open/api/fs/read/...fallback);reply::videoauto-loads only verified regular files inside the session workspace (Link::Inside).Link::Web(http(s)) andLink::Outsiderender as ordinary links on display to eliminate zero-click SSRF (including loopback/LAN/metadata addresses on remote servers) and outside-workspace video decode on macOS, pending the follow-up PR that restores them behind explicit click-to-load and remote-server address policy.Driven proof (Windows proved live: baseline
5a1a37bavs headc7c55276)c7c55276).bat/.lnk5a1a37ba: spawned bareexplorer.exe <path>explorer.exespawns; routed to safe revealsubst/ mapped-drive / junction forms (\\,//,file://host,file:///\\,file://localhost/\\,%5C%5C,\??/UNC/, WebDAV@port,subst-to-UNC, mapped SMB,subst-to-junction, outside junction)5a1a37ba: reached disk /explorer.exe--launch-trace-io), 0 reveals5a1a37ba: outside doc spawned bareexplorer.exe.bat,.lnk, UNC/WebDAV, outside doc5a1a37ba:.batand.lnkspawned bareexplorer.exeexplorer.exespawns, 0 UNC/SMB I/O calls; valid local files safely revealed/evil.bat, SVG at/evil.hta, PNG at/CON.foo.png)5a1a37ba: wroteopencode-drag\...\evil.batand spawned"explorer" ...\evil.batevil.bmpand safely revealed (0explorerspawns); SVG wrote 0 files / 0 spawns;/CON.foo.pngwroteimage.pngand safely revealed;in folder name (repo; new-tab cmdvsrepo-clean)5a1a37ba: spawnedwt.exe -w new -d "...\repo; new-tab cmd";folder refused (0wt.exespawns);repo-cleanstill opened normallySystem:Reveal(UNC,subst-to-UNC, mapped SMB, junction, outside.bat)5a1a37ba: opened UNC/mapped/subst/junction paths and spawnedexplorer.exe5 timesexplorer.exespawns; valid local.batsafely revealedILCreateFromPathW->(parent, 1, &child, 0)) on.lnk,.url,.zip,.search-ms,dir.{CLSID}, and plain directory5a1a37ba: used(full, 0, NULL, 0)withexplorer.exe /selectfallback(parent, child)PIDL (childPidlBytes > 0).htmland.mp4linksd616d701:.mp4fell back to 5/api/fs/read/junc-outside/clip.mp4requestspage.html/clip.mp4) and 0/api/fs/read/fallback requestscldflt.syssync root:docs0x9000601A, hydratedindex.html, dehydrateddehydrated.txt0x9000401A, hostile junctionjunc_out0xA0000003)d616d701: blanketFILE_ATTRIBUTE_REPARSE_POINTcheck rejected0x410Cloud Filter tags underPHCM_EXPOSE_PLACEHOLDERShydrations=0), whilejunc_outinside the Cloud Filter directory is still refused (0 target opens, 0 reveals)918d24f9: outside Open file calledopen_default;std::fs::metadataprobed network/junction paths; standalonehttp(s)and outside.mp4auto-loaded on display.batomits Open file and offers safe Reveal only; inside.mdOpen file opens built-in viewer;subst/junction right-clicks make 0 disallowed I/O calls; standalonehttp(s)and outside.mp4render as plain links (0 HTTP hits, 0 disk opens on display)oc-preview://engine suite (cross-OS/remote/workon Windows, 15 broad roots, T1–T11, Cloud Filter)1ee0f1f8:is_safe_workspace_rootbroke cross-OS/remote/workpreviewsALL_PASS(15/15 broad roots refused,/remote/workremote preview 200/206 ok, Cloud Filter hydrated+dehydrated ok, junction blocked)ws-alias -> workspace, fail-closed)5d50c6f7: usedstd::fs::canonicalizeon the rootCouldn't open/Refusing symlink or reparse point, inline video stays a plain link, reply link menu omits local actions, HTML click refuses cleanlyPlatform proof scope: Windows proved live; macOS and Linux verified by reading (and cross-platform checks). Local OpenCode server
/api/fs/readsymlink confinement lives inanomalyco/opencode, outside this repository.Known limitations
On
dev(5d50c6f7),is_safe_workspace_rootandpath_within_rootusedstd::fs::canonicalizeon the workspace root, so a local workspace opened through a symlink or NTFS junction alias (for example~/work/proj -> ~/repos/projon macOS or a directory junction on Windows) worked across local file features. In this PR,verify_local_pathandverify_within_rootfail closed whenever any component of the path — including the workspace root itself — is a symlink or junction (only non-redirecting Windows Cloud Filter / OneDrive, WOF, and Dedup reparse tags are allowed). A user whose workspace is opened through a symlink or junction alias will see:Couldn't open—Refusing symlink or reparse point).Couldn't open—Refusing symlink or reparse point).file://preview tabs):browser_file_rootsand enginesafe_rootsreject the aliased root, so opening a workspace.htmlfile via legacyfile://refuses with the browser refusal banner/toast (Only web pages can open here), while Show the file's code in the Files viewer still works.Opening the workspace by its real (non-symlinked) folder path restores all six features immediately. This also applies when an OS-managed symlink or volume mount point sits in the workspace's ancestry — specifically Linux distributions where
/homesymlinks to/var/home(such as Fedora Silverblue/Atomic: open via/var/home/…instead) and Windows volumes or Dev Drives mounted at a folder rather than a drive letter (macOS/tmp//var//etc, APFS firmlinks, local/Volumes/<disk>, Windows 11 OneDrive Known Folder Move, and drive-letter Dev Drives all work). A follow-up PR will restore aliased local workspace roots safely by resolving the workspace root once at start-up (without touching SMB/autofs) and storing/passing that resolved physical root — never the raw alias — into every later check, with the home/system directory check applied to the resolved physical path case-insensitively on macOS and Windows.What the official app (
anomalyco/opencode,dev4390284d4d) doesNo — the official app never opens or runs a file through the OS default handler on a chat Markdown or terminal link click:
packages/session-ui/src/components/markdown.tsx->packages/app/src/runtime/plugin/render.tsx->packages/gui-plugins/src/file/renderer.tsx): Non-HTML files (including outside-workspace paths) are read through the OpenCode server API into the built-in read-only file tab viewer, and outside-workspace HTML files are refused with a toast (preview.outside). Neithershell.openPath,shell.showItemInFolder, norshell.openExternalis called. (checkFileLinkExistsinresolve-link.tsalso skips//UNC and~.)packages/gui-plugins/src/terminal/terminal-key-event.ts->terminal.tsx):terminalLinkTargetblocks plain paths, UNCfile://server/share,%2f/%5cinfile:, and non-http(s)/mailto:schemes; only relative inside-workspacefile:///links open in the built-in viewer.openExternalURL(packages/desktop/src/main/files/external-url.ts) callsshell.openExternalstrictly forhttp:,https:, andmailto:.shell.openPath/shell.showItemInFolder(packages/desktop/src/main/files/index.ts) are only called from explicit toolbar/menu Open in … and Reveal actions (plus browser download reveal and log export).Left for follow-ups
http(s)inline video behind an explicit user click + local-path verification and remote-server address policy (no loopback, private, link-local, or metadata hosts).mailto:attachment filter; explicit OS scheme allow-list; OSC 8 confirmation dialog hardening (strip bidi/controls, length cap, punycode host, no userinfo, IDN homoglyph confirmation); zero-click SSRF/disk-probe hardening (web_fetch, Markdown images,code_paths);plugins/file/init.luaubackslash..traversal fix;Links:Existsandservices/diag.rslocal-path guards; routing office/toast/System:OpenExternalthroughclassify_app_link; dropping.cmd/.batshim fallback infeatures/open-in/src/windows.rs; image menu "Reveal" label / SVG Save-As extension /wasm32SVG blob handling; blocking attacker-authoredopencode-code-path:links in Markdown; gatingHARNESS_OPEN_EXTERNAL_LOGout of release builds.Browser:History*andTakeAppLinkReviewto the built-in browser UI on user gesture; confine frecency/history writes and isolate non-default tabs; move and harden browser history import off the UI thread.