diff --git a/AGENTS.md b/AGENTS.md index c29f36ee..14cc0420 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -213,6 +213,14 @@ Security and privacy deployment, in place of a maintainer's signed tag. Mobile store signing and uploads may run in protected store-publishing environments, separately from builds, after release checksum and provenance verification. Store credentials never reach build jobs, pull requests or nightly builds. + Exception for local agent control (threat model S22): desktop Tarn may expose one local-only + IPC listener per running data directory for agent control. It is off by default, opens only + after the user opts in, and accepts connections only from the same OS user account. Each + connection needs explicit approval in Tarn before receiving browser data or controlling a + tab. It may use only a dedicated throwaway profile at Strict with per-site approval. Turning + the setting off closes the listener and ends the session, including profile cleanup. This + exception permits no TCP listener, local HTTP API, remote-debugging port, page-to-shell bridge + or new outbound request by the shell. 8. **No new or changed connections.** Do not add a request the shell makes, or change the receiver, content or frequency of one listed in `PRIVACY.md` ("Connections the browser itself makes"). No telemetry, analytics, accounts or crash upload. Exception, decided by the diff --git a/docs/threat-model.md b/docs/threat-model.md index fec0b4c4..8adefe33 100644 --- a/docs/threat-model.md +++ b/docs/threat-model.md @@ -27,7 +27,7 @@ settings per client are in `cryptography.md`; the actors, components and externa | S13 | Medium | Supply chain | `cargo-deny`, `cargo audit`, committed lockfile, crates pinned to exact versions (GPUI `=0.2.2`, no git dependencies), SBOM per release. | `deny.toml` (advisories, bans, licences and sources in the `deny` job on every pull request, advisories nightly), lockfile, Renovate, CycloneDX SBOM on each tagged release, made in a job without `id-token`; Inno Setup 6.7.3 for the Windows installer pinned by SHA-256 (`release.yml`), Ninja for the Chromium build pinned by SHA-256 (`scripts/fetch-ninja.sh`, release and CI), Gradle 8.14.3 for the Android build pinned by SHA-256 (`mobile/android/gradle.sh`; no wrapper jar in the repository). CEF archive: SHA-256 recorded from `chromium-update.yml`'s download, checked by each build's own download (`scripts/fetch-cef.sh`). The `cef` pin and the locked `cef-dll-sys` move with the CEF build in `chromium-update.yml`'s pull requests (the newest unyanked crates.io release with a stable CEF build on every platform, no waiting period), which need a maintainer's approval and pass CI and `deny`; the pull request shows only their versions and checksums, not the crates' source, which CI builds without secrets; `tag` does not release a merge whose `cef` crate differs from the latest release's: it opens an issue and a maintainer releases it. Both trust `cef-builds.spotifycdn.com` and one network route to it; no second download over another route and no waiting period. No independent build exists. | | S21 | Medium | Memory-safety bugs in our FFI code | `unsafe` confined to two crates, each block documented with its invariant and enforced by lint. | `forbid(unsafe_code)` outside engine/platform, except `crates/app-dll`, whose only `unsafe` is its `RunWinMain` export for CEF's Windows launcher and the documented call inside it; `undocumented_unsafe_blocks` denied. | | S14 | Medium | Attacker-controlled titles and favicons parsed by the shell | Titles are bounded plain text. Favicons have byte and dimension caps and are decoded with limits. | Titles cut to 1024 characters in the engine, unchanged titles dropped, and bounded for display by `ui::text::bounded_title`. Find in Tabs snippets of page text (`WebView::find_text`), never from a Lockdown tab (found by title and address only): read in the same isolated world with the query as a JS string literal, at most 3 per tab of 320 characters each (cut again in Rust), shown as `bounded_title` plain text, never stored. Page text read for translation (feature `translation`) is capped at 2,000 nodes of 2,000 characters and 100,000 in all, handed only to Apple's on-device Translation framework and written back by the client world as text node data, never markup, only while the tab shows the offered page; never under Lockdown. The page can observe the rewrite and so learn the target language. Favicons (`engine::favicon`): links read and fetched in the engine's isolated world (WebKit's client content world, a DevTools isolated world in Chromium), hrefs over 2048 and `sizes` over 256 characters dropped there, so content rules, proxy and user agent apply; https URLs on the page's site, or on another site's host only when the page itself already loaded a resource from that exact host (default port; the isolated world reports at most 64 such hosts from Resource Timing, which lists only requests the page really made, so content rules have already applied to them), so a page cannot make the browser contact a server it has not used; cookies only for the page's own origin; another site's icon is fetched as a CORS request without credentials; no redirects are followed (`redirect: 'error'`), so no request goes past the checked URL; 10 s timeout, 256 KiB cap, and only while the tab still shows the requesting origin; SVG icons are rasterised to PNG by the engine (as an image, so no script runs); decoded with a 1024 px / 16 MiB limit and re-encoded as 64×64 PNG; stored per profile and wiped with history; a failed fetch is retried on the site's next page load, until three fetches have failed in a session; an icon stored over 30 days ago is fetched again the same way on the site's next load and replaced only on success; a subdomain without its own icon shows its registrable domain's, never across a public suffix; not fetched under Lockdown. Linux (`tarn.webview` `readIconLinks` and `fetchIcon`) runs the same scripts in its WebKitGTK script world `tarn` and iOS in its `WKContentWorld`, with the same Rust checks (`engine::favicon`); their components keep only https URLs, at most `favicon::MAX_CANDIDATES` (`favicon::fetch_urls`), and always fetch with the `favicon::MAX_BYTES` cap. Reader mode (`engine::reader`) reads the article in the same isolated world as plain strings, at most 200 KB and 10,000 characters a paragraph without control characters, re-checked by `Article::parse` (`serde_json`, input over 800 KB refused); the check for an article after each load runs only on http(s) pages and never under Lockdown, and GPUI draws them as text only; nothing of it is stored. Clean Up (`browser_core::cleanup`) reads only the http(s) host (at most 10 labels), the first 8 path segments and the first 1,024 characters of the title, never the query, fragment or user info, on the device; it keeps nothing but an in-memory undo record of tab and group ids and the names of the groups it made or opened, dropped with its toast. The link under the pointer (status bubble) is cut to 4,096 characters where the engine hands it over (`view_policy::MAX_HOVERED_LINK`; WebKit, CEF and the Linux web view component), parsed as a URL so its host shows as punycode and other characters percent-encoded, shown without user info (also inside `blob:`) with the host's end kept (`host_tail`) and the rest bounded by `bounded_url` (`browser_core::link_status`); the origin is drawn whole and only the rest is cut to fit, as plain text in a window the pointer passes through; never stored. The mini-player's title comes from the page's media session or document title through `page_ops::MediaState::parse` (cleaned and cut like a tab title); no artwork is fetched. | -| S22 | Medium | Other local programs driving the browser | No listening sockets, no remote-debugging port, no local HTTP API; checked by the egress test. | No listener exists. Chromium ignores Chromium and CEF switches on Tarn's argv (`command_line_args_disabled`), and the browser process also removes the switches that turn off a sandbox, site isolation or web security, run a program in front of a child (`renderer-cmd-prefix`, `gpu-launcher`, …) or open remote debugging, before its children start (`engine::chromium::runtime`, not yet run against a launch with those switches). `crates/app/tests/egress.rs` launches the shell with filter-list updates off, loads a page from a local server and fails if `lsof` (sampled every 500 ms) shows any socket of the shell process, listening or connected; it is ignored by default because it opens a window and runs by hand with `cargo test -p app --tests -- --ignored`; no workflow runs it. The filter-list download itself is not covered. | +| S22 | Medium | Other local programs driving the browser | No listener by default, no remote-debugging port, no local HTTP API. Agent control is the sole exception: an opt-in OS-local endpoint restricted to the same OS user. The user must approve each agent connection and each site in Tarn before the agent can use it. Tarn must isolate each session in a throwaway Strict profile, and close the listener and wipe the session when disabled. | No listener exists in the current implementation. The egress check continues to apply with agent control off. Chromium ignores Chromium and CEF switches on Tarn's argv (`command_line_args_disabled`), and the browser process also removes the switches that turn off a sandbox, site isolation or web security, run a program in front of a child (`renderer-cmd-prefix`, `gpu-launcher`, …) or open remote debugging, before its children start (`engine::chromium::runtime`, not yet run against a launch with those switches). `crates/app/tests/egress.rs` launches the shell with filter-list updates off, loads a page from a local server and fails if `lsof` (sampled every 500 ms) shows any socket of the shell process, listening or connected; it is ignored by default because it opens a window and runs by hand with `cargo test -p app --tests -- --ignored`; no workflow runs it. The filter-list download itself is not covered. | | S23 | Low | Page floods the user with dialogs, popups or tabs | Rate limits and a "stop this page" option. Pop-ups only after a user gesture. | 5 prompts and 3 popups per tab per 10 s, shared with the popups that tab opens, at most 8 queued; pages cannot open windows without a user gesture (`javaScriptCanOpenWindowsAutomatically` false; WebKit's default is true); "Block requests from this page" declines the queue and further requests until the next navigation; sign-in requests only from the page's own origin (scheme, host and port), at most 3 attempts. A site's "Block" pop-up rule and the pop-up, malware and adult sets refuse the rest, with a notice that offers to open it once (`app/tests/blocking.rs`). The mini-player's Play runs as the user's gesture, which the page's own scripts share for that moment as after a click; Pause and Seek do not on Chromium. Residual: WebKit treats every script of the shell's isolated world as a gesture, so on macOS with WebKit, Linux and iOS a Pause or Seek also lends the page one gesture. | | S24 | High | A page abuses or subverts Tarn's YouTube script in the page world | The script is compiled into the app, runs only on YouTube's hosts (exact match or dot-suffix, never `accounts.youtube.com`), captures the built-ins it uses before any page script runs, removes only allowlisted keys, never touches the DOM, storage, cookies or the network, defines no global and has no bridge to the shell. The signed bundle may change only which keys it removes. | `shield::youtube` and `youtube.js`; `youtube::parse` accepts at most 32 ASCII-letter keys and refuses keys playback needs; `data_store::install_scripts` rebuilds a controller's scripts in one place, so the referrer script, the Bitwarden passkey script (S15, S18) and the Netflix visibility script survive every change. Node sandbox test (`shield/tests/youtube.rs`) covers host gating, poisoned built-ins and every hook. The page can detect and undo the YouTube script on its own pages; that only brings its ads back. The Netflix script runs only on `netflix.com` hosts, makes the page see itself visible and focused, defines no global and has no bridge to the shell. Undoing it only lets Netflix stop playback again. On Windows both scripts reach Chromium's main world through `Page.addScriptToEvaluateOnNewDocument`, registered before a view's first load: the Netflix script in every view but Lockdown's, the YouTube script only in views made for a site where blocking is not paused; a new or switched-off YouTube script replaces the registered one for each view's next document. On Linux both are WebKitGTK page-world user scripts at document start in every frame (`linux/src/webview/scripts.rs` `apply_page_scripts`), installed in no Lockdown view and wrapped by `page_scripts::outside_lockdown` so they skip hosts set to Lockdown; the YouTube one only while Block YouTube ads is on (`youtube` prop), built by `youtube::script` from the bundle's `youtube::config`. Linux has no per-site pause, so blocking is never paused there. Display test `youtube_and_netflix_scripts_run_only_on_their_hosts_and_never_under_lockdown`. | | S25 | Medium | User opens a malware, phishing or scam site | Domain sets from curated lists checked on every navigation in every frame, including redirects and downloads, before the request is made; WebKit's fraudulent-website check stays on with the malware switch. | `nav_policy::gate` runs in `decide_policy` before the sub-frame and download branches; main frames get a native warning page (`app::blocking`) with "Go Back" as the default button, and "Visit Anyway" only for malware, ignoring clicks for 700 ms from when its tab becomes visible, and remembered per host and profile in memory until quit. Subresources from the two most curated malware lists are blocked by a content rule list that pausing a site does not lift. Sets of categories switched off are not loaded. New domains are missed until the next daily bundle. |