diff --git a/.github/workflows/chromium-update.yml b/.github/workflows/chromium-update.yml index 9b43eb4d..2002fee3 100644 --- a/.github/workflows/chromium-update.yml +++ b/.github/workflows/chromium-update.yml @@ -305,6 +305,7 @@ jobs: NOTARY_API_KEY_ID: ${{ secrets.NOTARY_API_KEY_ID }} NOTARY_API_ISSUER: ${{ secrets.NOTARY_API_ISSUER }} SPARKLE_ED_PRIVATE_KEY: ${{ secrets.SPARKLE_ED_PRIVATE_KEY }} + HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} report: needs: [watch, propose, open, tag, build] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c6e3acb..cbc4f710 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: components: clippy, rustfmt - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - run: for d in . nsh-shared mobile linux; do (cd "$d" && cargo fmt --all --check); done - - run: scripts/check-workflows.sh && scripts/check-workflows.test.sh && scripts/ci-changes.test.sh && scripts/check-dco.test.sh + - run: scripts/check-workflows.sh && scripts/check-workflows.test.sh && scripts/ci-changes.test.sh && scripts/check-dco.test.sh && scripts/attestation.test.sh - run: python3 scripts/mobile-store.test.py - run: scripts/third-party-licenses.sh --check - run: cargo clippy $CRATES --all-targets --locked -- -D warnings @@ -112,7 +112,7 @@ jobs: save-if: ${{ github.ref == 'refs/heads/main' }} - run: cargo clippy $CRATES --all-targets --locked -- -D warnings - run: cargo test $CRATES --locked - - run: scripts/dmg.test.sh && scripts/windows-feed.test.sh + - run: scripts/dmg.test.sh && scripts/windows-feed.test.sh && scripts/homebrew-cask.test.sh - name: Chromium feature run: | scripts/fetch-ninja.sh "$RUNNER_TEMP/ninja" @@ -148,6 +148,8 @@ jobs: # Links tarn.dll, whose delay-load flags apply only to the real cdylib. - run: cargo build --locked -p app-dll - run: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/sign-windows.test.ps1 + - run: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/install-script.test.ps1 + - run: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/set-exe-icon.test.ps1 nsh-shared: needs: changes diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31075b63..d584635f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,8 @@ on: required: false CHROMIUM_UPDATE_APP_KEY: required: false + HOMEBREW_TAP_DEPLOY_KEY: + required: false permissions: {} @@ -196,7 +198,9 @@ jobs: scripts/package-windows.sh dist/Tarn setup="$(scripts/installer-windows.sh dist/Tarn dist | tail -n1)" mv "$setup" "dist/Tarn-${TAG}-windows-x64-setup-unsigned.exe" - cd dist && 7z a -tzip "Tarn-${TAG}-windows-x64-unsigned.zip" Tarn >/dev/null && rm -rf Tarn + cd dist && 7z a -tzip "Tarn-${TAG}-windows-x64-unsigned.zip" Tarn >/dev/null + # The same folder runs without installing once tarn-portable sits beside tarn.exe (browser_core::portable_dir). + touch Tarn/tarn-portable && 7z a -tzip "Tarn-${TAG}-windows-x64-portable-unsigned.zip" Tarn >/dev/null && rm -rf Tarn - id: upload uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -563,7 +567,8 @@ jobs: if-no-files-found: error # Runs no build code: it takes each build job's files by their fixed names, so no job can replace - # another platform's file, then writes SHA256SUMS and attests it with the binaries and SBOMs. + # another platform's file, fills install.ps1's template with the Windows files it took, then writes + # SHA256SUMS and attests it with the binaries, the SBOMs and install.ps1. # Engine updates (chromium-update.yml) and manual runs ship the macOS bundle alone, without # waiting for the rest. assets: @@ -577,6 +582,13 @@ jobs: id-token: write attestations: write steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs.commit }} + path: source + persist-credentials: false + sparse-checkout: packaging/windows/install.ps1 + sparse-checkout-cone-mode: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: artifact-ids: ${{ needs.build.outputs.artifact }} @@ -657,13 +669,24 @@ jobs: else take signed "Tarn-${TAG}.zip" "Tarn-${TAG}.dmg" appcast.xml windows-update.json windows-update.json.sig take sbom-clients "Tarn-${TAG}-windows-x64.cdx.json" "Tarn-${TAG}-linux.cdx.json" "Tarn-${TAG}-ios.cdx.json" "Tarn-${TAG}-android.cdx.json" - take windows "Tarn-${TAG}-windows-x64-unsigned.zip" "Tarn-${TAG}-windows-x64-setup-unsigned.exe" + take windows "Tarn-${TAG}-windows-x64-unsigned.zip" "Tarn-${TAG}-windows-x64-portable-unsigned.zip" "Tarn-${TAG}-windows-x64-setup-unsigned.exe" take linux "tarn_${version}_debian*_amd64.deb" "tarn_${version}_ubuntu*_amd64.deb" \ "tarn-${version}-*.x86_64.rpm" "tarn-${version}-*-x86_64.pkg.tar.zst" take ios "Tarn-${TAG}-ios-unsigned.zip" take android "Tarn-${TAG}-android-unsigned.apk" "Tarn-${TAG}-android-unsigned.aab" take android-sbom "Tarn-${TAG}-android-java.cdx.json" fi + if [[ "$MACOS_ONLY" != true ]]; then + # Fills the template's placeholders with this run's Windows files; text substitution only. + setup="Tarn-${TAG}-windows-x64-setup-unsigned.exe" portable="Tarn-${TAG}-windows-x64-portable-unsigned.zip" + [[ "$TAG" =~ ^(v[0-9]+(\.[0-9]+){1,3}|nightly)$ && "$GITHUB_REPOSITORY" =~ ^[A-Za-z0-9-]+/[A-Za-z0-9._-]+$ ]] \ + || { echo "unexpected tag $TAG or repository $GITHUB_REPOSITORY for install.ps1" >&2; exit 1; } + sed -e "s|@TAG@|$TAG|g" -e "s|@REPO@|$GITHUB_REPOSITORY|g" \ + -e "s|@SETUP_NAME@|$setup|g" -e "s|@SETUP_SHA256@|$(sha256sum "dist/$setup" | cut -d' ' -f1)|g" \ + -e "s|@PORTABLE_NAME@|$portable|g" -e "s|@PORTABLE_SHA256@|$(sha256sum "dist/$portable" | cut -d' ' -f1)|g" \ + source/packaging/windows/install.ps1 > dist/install.ps1 + ! grep -qE '@[A-Z0-9_]+@' dist/install.ps1 || { echo "install.ps1 keeps a placeholder" >&2; exit 1; } + fi cd dist && sha256sum ./* > SHA256SUMS - id: predicate env: @@ -683,6 +706,7 @@ jobs: dist/*.apk dist/*.aab dist/*.cdx.json + dist/*.ps1 dist/SHA256SUMS predicate-type: https://github.com/Quavon-dev/tarn-browser/attestations/release/v1 predicate: ${{ steps.predicate.outputs.json }} @@ -719,8 +743,21 @@ jobs: sha256sum --strict -c SHA256SUMS extra="$(comm -23 <(find . -maxdepth 1 -type f ! -name SHA256SUMS | sort) <(awk '{print $2}' SHA256SUMS | sort))" [[ -z "$extra" ]] || { echo "dist holds files SHA256SUMS does not list: $extra" >&2; exit 1; } + - if: ${{ !inputs.nightly }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs.commit }} + path: source + persist-credentials: false + sparse-checkout: | + CHANGELOG.md + packaging/cef.lock + packaging/updates.conf + scripts/attestation.sh + sparse-checkout-cone-mode: false # Windows checks windows-update.json in the latest release; a macOS-only release carries the last - # signed one over unchanged, so its signature still holds and Windows keeps a verified feed. + # signed one over unchanged, so its signature still holds and Windows keeps a verified feed, and + # the last install.ps1, so the install command keeps working. - if: (github.event_name != 'push' || inputs.commit != '') && !inputs.nightly && !inputs.full env: GH_TOKEN: ${{ github.token }} @@ -735,6 +772,13 @@ jobs: else echo "::warning::the latest release has no Windows update feed to carry over" fi + # install.ps1 names the earlier release's Windows files by tag and SHA-256, so it stays valid as well. + if grep -qx install.ps1 <<<"$assets"; then + mkdir -p carried + gh release download --pattern install.ps1 --dir carried + source/scripts/attestation.sh script carried/install.ps1 >/dev/null + mv carried/install.ps1 dist/ + fi - if: inputs.nightly env: GH_TOKEN: ${{ github.token }} @@ -753,17 +797,6 @@ jobs: --notes "Nightly build of $COMMIT: the latest changes, before they are tested in a release. Settings › General › Nightly builds updates to it on macOS and Windows." [[ "$(gh api "repos/$GH_REPO/git/ref/tags/$TAG" --jq .object.sha)" == "$COMMIT" ]] \ || { echo "$TAG does not name $COMMIT" >&2; gh release delete "$TAG" --yes; exit 1; } - - if: ${{ !inputs.nightly }} - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - ref: ${{ inputs.commit }} - path: source - persist-credentials: false - sparse-checkout: | - CHANGELOG.md - packaging/cef.lock - packaging/updates.conf - sparse-checkout-cone-mode: false - if: ${{ !inputs.nightly }} env: GH_TOKEN: ${{ github.token }} @@ -851,11 +884,33 @@ jobs: own="$(pair "$highest")" || rc=$? [[ "$rc" != 2 ]] || { echo "could not download the Windows feed of $highest" >&2; exit 1; } fi - if [[ -n "$best" && ( -z "$own" || "$(printf '%s\n%s\n' "$own" "$best_version" | sort -V | tail -n1)" == "$best_version" ) ]] \ - && ! { cmp -s "pair/$best/windows-update.json" "pair/$highest/windows-update.json" \ + if [[ -n "$best" && ( -z "$own" || "$(printf '%s\n%s\n' "$own" "$best_version" | sort -V | tail -n1)" == "$best_version" ) ]]; then + if ! { cmp -s "pair/$best/windows-update.json" "pair/$highest/windows-update.json" \ && cmp -s "pair/$best/windows-update.json.sig" "pair/$highest/windows-update.json.sig"; }; then - gh release upload "$highest" "pair/$best/windows-update.json" "pair/$best/windows-update.json.sig" --clobber - echo "::notice::$highest now carries the Windows feed of $best (Windows $best_version)" + gh release upload "$highest" "pair/$best/windows-update.json" "pair/$best/windows-update.json.sig" --clobber + echo "::notice::$highest now carries the Windows feed of $best (Windows $best_version)" + fi + # Apart from the feed, so a re-run repairs a script an earlier run failed to copy. + if gh release view "$best" --json assets --jq '.assets[].name' | grep -qx install.ps1; then + gh release download "$best" --pattern install.ps1 --dir "pair/$best" --clobber + origin="$(source/scripts/attestation.sh script "pair/$best/install.ps1")" + listed="$(gh release view "$highest" --json assets --jq '.assets[].name')" + if grep -qx install.ps1 <<<"$listed"; then + mkdir -p script + gh release download "$highest" --pattern install.ps1 --dir script --clobber + current="$(source/scripts/attestation.sh tag script/install.ps1)" + [[ -n "$current" ]] || { echo "install.ps1 of $highest names no release tag" >&2; exit 1; } + # Never replace a script that names a newer release than the one offered. + if ! cmp -s "pair/$best/install.ps1" script/install.ps1 \ + && [[ "$(printf '%s\n%s\n' "${current#v}" "${origin#v}" | sort -V | tail -n1)" == "${origin#v}" ]]; then + gh release upload "$highest" "pair/$best/install.ps1" --clobber + fi + else + gh release upload "$highest" "pair/$best/install.ps1" --clobber + fi + else + echo "::warning::$best has no install.ps1; $highest keeps its own, which may name older Windows files" + fi fi gh workflow run linux-repo.yml --ref main - name: Start mobile store uploads @@ -864,3 +919,70 @@ jobs: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} run: gh workflow run mobile-store.yml --ref main -f tag="$TAG" -f platform=both + + # Points the Homebrew cask in /homebrew-tarn at the latest release's disk image, checked + # against its attested SHA256SUMS. The tap's deploy key is the only secret of the homebrew-tap + # environment; without it the job notes that and changes nothing. + homebrew: + needs: publish + if: ${{ !inputs.nightly }} + # One push at a time, so an older run cannot land after a newer release's cask. + concurrency: + group: homebrew-tap + cancel-in-progress: false + runs-on: ubuntu-24.04 + environment: homebrew-tap + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ inputs.commit }} + path: source + persist-credentials: false + sparse-checkout: | + scripts/homebrew-cask.sh + scripts/attestation.sh + packaging/homebrew/tarn.rb.in + sparse-checkout-cone-mode: false + - id: cask + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + set -euo pipefail + # The latest release, not necessarily this run's: a queued newer run may have been replaced. + latest="$(gh release view --json tagName --jq .tagName)" + gh release download "$latest" --pattern SHA256SUMS --dir sums + source/scripts/attestation.sh sums sums/SHA256SUMS "$latest" + sha="$(awk -v dmg="./Tarn-${latest}.dmg" '$2 == dmg { print $1 }' sums/SHA256SUMS)" + source/scripts/homebrew-cask.sh "$latest" "$sha" "$GH_REPO" > tarn.rb + echo "tag=$latest" >> "$GITHUB_OUTPUT" + echo "ready=true" >> "$GITHUB_OUTPUT" + - if: steps.cask.outputs.ready == 'true' + env: + GH_REPO: ${{ github.repository }} + CASK_TAG: ${{ steps.cask.outputs.tag }} + DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} + run: | + set -euo pipefail + if [[ -z "$DEPLOY_KEY" ]]; then + echo "::notice::HOMEBREW_TAP_DEPLOY_KEY is not set; the Homebrew cask is not updated" + exit 0 + fi + work="$(mktemp -d)" + trap 'rm -rf "$work"' EXIT + printf '%s\n' "$DEPLOY_KEY" > "$work/key" + chmod 600 "$work/key" + # GitHub's host key, as https://api.github.com/meta lists it. + echo 'github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl' > "$work/known_hosts" + export GIT_SSH_COMMAND="ssh -i $work/key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$work/known_hosts" + git clone -q --depth 1 "git@github.com:${GH_REPO%%/*}/homebrew-tarn.git" tap + mkdir -p tap/Casks && cp tarn.rb tap/Casks/tarn.rb + git -C tap add Casks/tarn.rb + if git -C tap diff --cached --quiet; then + echo "the cask already names $CASK_TAG" + exit 0 + fi + git -C tap -c user.name=Tarn -c user.email=accounts@quavon.de commit -q -m "tarn ${CASK_TAG#v}" + git -C tap push -q origin HEAD diff --git a/.github/workflows/start-release.yml b/.github/workflows/start-release.yml index 5d138d3d..a0707420 100644 --- a/.github/workflows/start-release.yml +++ b/.github/workflows/start-release.yml @@ -73,3 +73,4 @@ jobs: NOTARY_API_ISSUER: ${{ secrets.NOTARY_API_ISSUER }} SPARKLE_ED_PRIVATE_KEY: ${{ secrets.SPARKLE_ED_PRIVATE_KEY }} CHROMIUM_UPDATE_APP_KEY: ${{ secrets.CHROMIUM_UPDATE_APP_KEY }} + HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} diff --git a/CHANGELOG.md b/CHANGELOG.md index fa480183..1472d105 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ All notable changes to Tarn are documented in this file. The format is based on ### Added +- Install with one command: `brew install --cask quavon-dev/tarn/tarn` on macOS (the cask follows + each release; Tarn keeps updating itself), and on Windows + `irm https://github.com/Quavon-dev/tarn-browser/releases/latest/download/install.ps1 | iex`, + which installs for the current user after checking the installer's SHA-256. +- A portable Windows download, `Tarn--windows-x64-portable-unsigned.zip`: unzip it anywhere and + start `tarn.exe`; profiles and site data stay in the `Data` folder beside it. It tells you when a new version + is out instead of installing one; `install.ps1 -Portable -Path ` unpacks or updates it, + keeping `Data`. +- Windows: `tarn.exe` shows the Tarn icon in Explorer, on the taskbar and in its windows instead + of the Chromium launcher's. - Sites that ask for a client certificate offer the certificates they accept and send only the one picked; Cancel sends none (macOS and Windows). Chromium tabs no longer send the first certificate without asking. diff --git a/PRIVACY.md b/PRIVACY.md index c101bb18..874a37fe 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -70,7 +70,7 @@ Settings › Privacy › Connections Tarn makes on macOS and Windows. | Connection | Receiver | What they see | Status | |---|---|---|---| -| Update check | GitHub (Releases of this repository) | Your IP address and Tarn version (on Windows only your IP address: Tarn fetches the signed `windows-update.json` and, when it names a later version, downloads that installer); from the `nightly` release in place of the latest one while Settings › General › Nightly builds is on | Once a day while Settings › General › Check for updates automatically is on (the default; on Windows an hour after a check that failed), and when you choose Tarn › Check for Updates… or Settings › General › Check Now, on macOS and Windows | +| Update check | GitHub (Releases of this repository) | Your IP address and Tarn version (on Windows only your IP address: Tarn fetches the signed `windows-update.json` and, when it names a later version, downloads that installer; a portable Tarn downloads nothing and offers the release page); from the `nightly` release in place of the latest one while Settings › General › Nightly builds is on | Once a day while Settings › General › Check for updates automatically is on (the default; on Windows an hour after a check that failed), and when you choose Tarn › Check for Updates… or Settings › General › Check Now, on macOS and Windows | | Filter-list update | GitHub (Releases of this repository) | Your IP address. Every list is downloaded whatever you switched on, so the download does not reveal your blocking choices | Once a day, on macOS, Windows and Linux; switch off in Settings › Privacy | | Fraudulent-website check | Apple, which relays Google Safe Browsing; done by WebKit itself, on macOS and iOS. On Android, Google directly, done by the system WebView's Safe Browsing | Shortened hashes of the addresses you visit, not the addresses | While "Block dangerous sites" is on (the default); off with that switch. On iOS and Android the web view's default, which Tarn leaves on and no switch turns off. Windows and Linux make no such check | | Extension catalog and downloads | GitHub (the repository you name, or the official catalog in `Quavon-dev/tarn-extensions`, not offered yet because its signing key is not set) | Your IP address and which repository or extension you install or check | Only when you click Install, Check for Updates or Show Official Extensions in Settings › Extensions; an Install in Tarn link from extensions.tarnbrowser.com makes no request until you click Install on the confirmation it opens there; switch off in Settings › Privacy (installing from a file keeps working) | diff --git a/README.md b/README.md index c18c82b5..65f9d31b 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,33 @@ Start with the macOS DMG or a Linux package from the [latest GitHub release](htt Windows packages are provided as unsigned previews. iOS and Android builds are still in testing. For platform requirements and installation options, visit the [Tarn download page](https://tarnbrowser.com/download). +**macOS, with Homebrew:** + +```sh +brew install --cask quavon-dev/tarn/tarn +``` + +**Windows, in PowerShell** (installs for your user, no administrator rights): + +```powershell +irm https://github.com/Quavon-dev/tarn-browser/releases/latest/download/install.ps1 | iex +``` + +**Windows, without installing:** download `Tarn--windows-x64-portable-unsigned.zip` from the +release, unzip it anywhere (a USB stick works) and start `tarn.exe`. It keeps its profiles, history and site data in the +`Data` folder next to it. At start Tarn tries to limit that folder to you, SYSTEM and +administrators and warns when it cannot, as on FAT or exFAT sticks; a folder that already has its +own protected permissions keeps them, so unzip it where only you can write. Downloads still go to your Downloads folder and an AI key +to Windows' Credential Manager. The same script unpacks or updates it: + +```powershell +& ([scriptblock]::Create((irm https://github.com/Quavon-dev/tarn-browser/releases/latest/download/install.ps1))) -Portable -Path D:\Tarn +``` + +The portable build tells you when a new version is out but does not update itself; run the command +again, or unzip the new version over the old folder, keeping `Data`. Chromium protects cookies and +saved passwords with your Windows account, so on another computer or account sites sign you out. + ## Features diff --git a/SECURITY.md b/SECURITY.md index 49a2fd2a..ff0db8a3 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -62,7 +62,9 @@ engines get their fixes from their vendors (see "Scope"). Every release on GitHub lists `SHA256SUMS`, and every binary carries a GitHub attestation signed by the release workflow of this repository, naming the commit and tag it was built from. A macOS-only release carries the previous release's `windows-update.json` and `.sig` over unchanged; -they are outside its `SHA256SUMS`, and their Ed25519 signature covers them. +they are outside its `SHA256SUMS`, and their Ed25519 signature covers them. It also carries +`install.ps1`, which is listed in the `SHA256SUMS` of the release it names in its `$Tag` line; +check it there. ```sh shasum -a 256 -c SHA256SUMS --ignore-missing diff --git a/crates/app/src/shared.rs b/crates/app/src/shared.rs index 24e0ff3a..a57b84be 100644 --- a/crates/app/src/shared.rs +++ b/crates/app/src/shared.rs @@ -132,6 +132,14 @@ pub(crate) fn start(cx: &mut App) -> bool { return false; } }; + #[cfg(windows)] + let kept = browser_core::portable_dir() + .filter(|dir| *dir == data_dir()) + .and_then(|dir| { + let e = engine::restrict_to_user(&dir).err()?; + Some(format!("Other accounts on this computer may read the portable data in {}: its permissions could not be limited to you ({e}).", dir.display())) + }) + .or(kept); let mut core = crate::browser::Core::open(&data_dir(), cfg!(feature = "chromium")); engine::startup::mark("store open"); core.storage_warning = core.storage_warning.or(kept); @@ -144,7 +152,9 @@ pub(crate) fn start(cx: &mut App) -> bool { let prefs = Cell::new(Prefs::load(&core.disk)); let (reports, mut update_reports) = mpsc::unbounded(); let (checks, nightly) = (prefs.get().get(crate::prefs::Pref::UpdateChecks), prefs.get().get(crate::prefs::Pref::NightlyUpdates)); - let updater = platform::updater::Updater::start(checks, nightly, &data_dir().join("updates"), move |report| drop(reports.unbounded_send(report))); + let updater = platform::updater::Updater::start(checks, nightly, browser_core::portable_dir().is_some(), &data_dir().join("updates"), move |report| { + drop(reports.unbounded_send(report)) + }); let (downloads, mut download_events) = mpsc::unbounded(); let core = Rc::new(AppCore { core, @@ -359,6 +369,9 @@ fn updater_reported(report: platform::updater::Report, cx: &mut App) { } Report::UpToDate => toast_front(browser_core::toast::Tone::Success, "Tarn is up to date", None, cx), Report::CheckFailed => toast_front(browser_core::toast::Tone::Warning, "Tarn could not check for updates", None, cx), + Report::UpdateAvailable { version, page } => { + toast_front(browser_core::toast::Tone::Info, format!("Tarn {version} is available"), page.map(crate::toast::Action::Download), cx) + } } #[cfg(any(feature = "chromium", windows))] check_chromium(cx); diff --git a/crates/app/src/toast.rs b/crates/app/src/toast.rs index 604233bb..52aa58e7 100644 --- a/crates/app/src/toast.rs +++ b/crates/app/src/toast.rs @@ -47,6 +47,8 @@ pub enum Action { UndoSort(Box<(bool, browser_core::cleanup::Undo)>), Reveal(PathBuf), RestartToUpdate, + /// Opens the release page of a later version in a new tab, for a portable Tarn. + Download(url::Url), /// Puts back the download list Clear removed from the private or normal store's profile. RestoreDownloads(Box<(bool, store::Id, Vec)>), /// Takes a held warning away. @@ -60,6 +62,7 @@ impl Action { Action::UndoSort(_) => "Undo Sort", Action::Reveal(_) => ui::controls::REVEAL, Action::RestartToUpdate => "Restart to Update", + Action::Download(_) => "Download", Action::RestoreDownloads(_) => "Undo", Action::Dismiss => "Dismiss", } @@ -274,6 +277,7 @@ impl Browser { } Some(Action::Reveal(path)) => engine::reveal_in_finder(&path), Some(Action::RestartToUpdate) => crate::shared::restart_to_update(cx), + Some(Action::Download(page)) => self.new_tab(&page, window, cx), Some(Action::RestoreDownloads(cleared)) => { let (private, profile_id, list) = *cleared; self.core.restore_downloads(private, profile_id, &list); diff --git a/crates/browser-core/src/lib.rs b/crates/browser-core/src/lib.rs index 58e2cbbb..ac2deba1 100644 --- a/crates/browser-core/src/lib.rs +++ b/crates/browser-core/src/lib.rs @@ -99,21 +99,36 @@ pub fn now() -> i64 { SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, |d| d.as_millis() as i64) } -/// Where Tarn keeps its data: `TARN_DATA_DIR`, else `base`, else the platform's default. iOS and -/// Android have none, so their host passes `base`. +/// Where Tarn keeps its data: `TARN_DATA_DIR`, else `base`, else a portable Tarn's folder, else +/// the platform's default. iOS and Android have none, so their host passes `base`. pub fn data_dir(base: Option<&Path>) -> Option { let platform = if cfg!(windows) { "LOCALAPPDATA" } else { "XDG_DATA_HOME" }; - resolve_data_dir(std::env::var_os("TARN_DATA_DIR"), base, std::env::home_dir(), std::env::var_os(platform)) + resolve_data_dir(std::env::var_os("TARN_DATA_DIR"), base.map(Path::to_owned).or_else(portable_dir), std::env::home_dir(), std::env::var_os(platform)) +} + +/// Marks a portable Tarn: a file of this name beside the executable keeps its data in `Data` there. +const PORTABLE_MARKER: &str = "tarn-portable"; + +/// The data folder of a portable Tarn, on Windows only, decided once per run. macOS keeps site data +/// under `~/Library/WebKit` and secrets in the Keychain; Linux has no portable download yet. +pub fn portable_dir() -> Option { + static DIR: std::sync::OnceLock> = std::sync::OnceLock::new(); + DIR.get_or_init(|| if cfg!(windows) { portable_dir_beside(&std::env::current_exe().ok()?) } else { None }).clone() +} + +fn portable_dir_beside(exe: &Path) -> Option { + let dir = exe.parent().filter(|d| d.is_absolute())?; + dir.join(PORTABLE_MARKER).is_file().then(|| dir.join("Data")) } /// `xdg` is `XDG_DATA_HOME` on Linux and `LOCALAPPDATA` on Windows. #[cfg_attr(not(target_os = "linux"), allow(unused_variables))] -fn resolve_data_dir(tarn: Option, base: Option<&Path>, home: Option, xdg: Option) -> Option { +fn resolve_data_dir(tarn: Option, base: Option, home: Option, xdg: Option) -> Option { if let Some(dir) = tarn { return Some(dir.into()); } if let Some(base) = base { - return Some(base.to_owned()); + return Some(base); } #[cfg(target_os = "macos")] return Some(home.unwrap_or_default().join("Library/Application Support/Tarn")); @@ -428,7 +443,7 @@ mod tests { #[test] fn data_dir_prefers_the_override_then_the_host_then_the_platform() { let resolve = |tarn: Option<&str>, base: Option<&str>, home: Option<&str>, xdg: Option<&str>| { - resolve_data_dir(tarn.map(OsString::from), base.map(Path::new), home.map(PathBuf::from), xdg.map(OsString::from)) + resolve_data_dir(tarn.map(OsString::from), base.map(PathBuf::from), home.map(PathBuf::from), xdg.map(OsString::from)) }; assert_eq!(resolve(Some("/t"), Some("/b"), Some("/h"), None), Some("/t".into())); assert_eq!(resolve(None, Some("/b"), Some("/h"), None), Some("/b".into())); @@ -448,6 +463,19 @@ mod tests { } } + #[test] + fn portable_dir_needs_the_marker_beside_the_executable() { + let dir = tempfile::tempdir().unwrap(); + let exe = dir.path().join("tarn.exe"); + assert_eq!(portable_dir_beside(&exe), None); + std::fs::create_dir(dir.path().join(PORTABLE_MARKER)).unwrap(); + assert_eq!(portable_dir_beside(&exe), None, "a folder is no marker"); + std::fs::remove_dir(dir.path().join(PORTABLE_MARKER)).unwrap(); + std::fs::write(dir.path().join(PORTABLE_MARKER), "").unwrap(); + assert_eq!(portable_dir_beside(&exe), Some(dir.path().join("Data"))); + assert_eq!(portable_dir_beside(Path::new("tarn")), None, "only an absolute path names a folder"); + } + fn downloads() -> Rc { Rc::new(|_| {}) } diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index 0f440999..3cd55c54 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -54,6 +54,7 @@ windows-sys = { version = "=0.61.2", features = [ "Win32_System_LibraryLoader", "Win32_System_Registry", "Win32_Security", + "Win32_Security_Authorization", "Win32_System_Threading", "Win32_UI_HiDpi", "Win32_UI_Input_KeyboardAndMouse", diff --git a/crates/engine/src/host_windows.rs b/crates/engine/src/host_windows.rs index 899ddce8..bdcc210c 100644 --- a/crates/engine/src/host_windows.rs +++ b/crates/engine/src/host_windows.rs @@ -323,6 +323,116 @@ fn register_browser(exe: &str) -> bool { registered } +/// Gives `dir`, a portable Tarn's data folder, a protected access list for the current user, +/// SYSTEM and Administrators, as Local AppData has for an install, unless it has a protected one +/// already; everything inside inherits it. Fails on a file system without permissions, such as +/// exFAT, and on a folder whose access list the user may not change. +pub fn restrict_to_user(dir: &std::path::Path) -> std::io::Result<()> { + use std::os::windows::ffi::OsStrExt; + use windows_sys::Win32::Foundation::{ERROR_INVALID_SECURITY_DESCR, ERROR_SUCCESS, LocalFree}; + use windows_sys::Win32::Security::Authorization::{ + ConvertStringSecurityDescriptorToSecurityDescriptorW, SDDL_REVISION_1, SE_FILE_OBJECT, SetNamedSecurityInfoW, + }; + use windows_sys::Win32::Security::{ACL, DACL_SECURITY_INFORMATION, GetSecurityDescriptorDacl, PROTECTED_DACL_SECURITY_INFORMATION, PSECURITY_DESCRIPTOR}; + std::fs::create_dir_all(dir)?; + let path: Vec = dir.as_os_str().encode_wide().chain(Some(0)).collect(); + if dacl_protected(&path)? { + return Ok(()); + } + let sddl = wide(&format!("D:P(A;OICI;FA;;;{})(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)", current_user_sid()?)); + let mut descriptor: PSECURITY_DESCRIPTOR = std::ptr::null_mut(); + // SAFETY: `sddl` is NUL-terminated; on success `descriptor` is a LocalAlloc block freed below. + if unsafe { ConvertStringSecurityDescriptorToSecurityDescriptorW(sddl.as_ptr(), SDDL_REVISION_1, &mut descriptor, std::ptr::null_mut()) } == 0 { + return Err(std::io::Error::last_os_error()); + } + let (mut present, mut defaulted, mut dacl) = (0, 0, std::ptr::null_mut::()); + // SAFETY: `descriptor` is the valid descriptor made above; `dacl` points into it. + let found = unsafe { GetSecurityDescriptorDacl(descriptor, &mut present, &mut dacl, &mut defaulted) } != 0 && present != 0; + let status = if found { + // SAFETY: `path` is NUL-terminated and `dacl` stays valid until `descriptor` is freed below. + unsafe { + SetNamedSecurityInfoW( + path.as_ptr(), + SE_FILE_OBJECT, + DACL_SECURITY_INFORMATION | PROTECTED_DACL_SECURITY_INFORMATION, + std::ptr::null_mut(), + std::ptr::null_mut(), + dacl, + std::ptr::null(), + ) + } + } else { + ERROR_INVALID_SECURITY_DESCR + }; + // SAFETY: frees the block ConvertStringSecurityDescriptorToSecurityDescriptorW allocated. + unsafe { LocalFree(descriptor) }; + if status == ERROR_SUCCESS { Ok(()) } else { Err(std::io::Error::from_raw_os_error(status as i32)) } +} + +/// Whether the object at `path` (NUL-terminated) has a protected access list, one that inherits nothing. +fn dacl_protected(path: &[u16]) -> std::io::Result { + use windows_sys::Win32::Foundation::{ERROR_SUCCESS, LocalFree}; + use windows_sys::Win32::Security::Authorization::{GetNamedSecurityInfoW, SE_FILE_OBJECT}; + use windows_sys::Win32::Security::{DACL_SECURITY_INFORMATION, GetSecurityDescriptorControl, PSECURITY_DESCRIPTOR, SE_DACL_PROTECTED}; + let mut descriptor: PSECURITY_DESCRIPTOR = std::ptr::null_mut(); + // SAFETY: `path` is NUL-terminated; on success `descriptor` is a LocalAlloc block freed below. + let status = unsafe { + GetNamedSecurityInfoW( + path.as_ptr(), + SE_FILE_OBJECT, + DACL_SECURITY_INFORMATION, + std::ptr::null_mut(), + std::ptr::null_mut(), + std::ptr::null_mut(), + std::ptr::null_mut(), + &mut descriptor, + ) + }; + if status != ERROR_SUCCESS { + return Err(std::io::Error::from_raw_os_error(status as i32)); + } + let (mut control, mut revision) = (0u16, 0u32); + // SAFETY: `descriptor` is valid until it is freed below. + let read = unsafe { GetSecurityDescriptorControl(descriptor, &mut control, &mut revision) } != 0; + // SAFETY: frees the block GetNamedSecurityInfoW allocated. + unsafe { LocalFree(descriptor) }; + Ok(read && control & SE_DACL_PROTECTED != 0) +} + +/// The SID of the user this process runs as, in SDDL's `S-1-…` form. +fn current_user_sid() -> std::io::Result { + use windows_sys::Win32::Foundation::{CloseHandle, HANDLE, LocalFree}; + use windows_sys::Win32::Security::Authorization::ConvertSidToStringSidW; + use windows_sys::Win32::Security::{GetTokenInformation, TOKEN_QUERY, TOKEN_USER, TokenUser}; + use windows_sys::Win32::System::Threading::{GetCurrentProcess, OpenProcessToken}; + let mut token: HANDLE = std::ptr::null_mut(); + // SAFETY: the current-process pseudo handle needs no closing; `token` is closed below. + if unsafe { OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &mut token) } == 0 { + return Err(std::io::Error::last_os_error()); + } + let mut buffer = vec![0u64; 128]; + let mut written = 0; + // SAFETY: `buffer` is writable for the size passed and aligned for TOKEN_USER. + let read = unsafe { GetTokenInformation(token, TokenUser, buffer.as_mut_ptr().cast(), (buffer.len() * 8) as u32, &mut written) } != 0; + let error = std::io::Error::last_os_error(); + // SAFETY: closes the token opened above. + unsafe { CloseHandle(token) }; + if !read { + return Err(error); + } + let mut text: windows_sys::core::PWSTR = std::ptr::null_mut(); + // SAFETY: `buffer` now holds a TOKEN_USER whose SID points into `buffer`; on success `text` is a + // LocalAlloc string freed below. + if unsafe { ConvertSidToStringSidW((*buffer.as_ptr().cast::()).User.Sid, &mut text) } == 0 { + return Err(std::io::Error::last_os_error()); + } + // SAFETY: `text` is a NUL-terminated wide string until it is freed below. + let sid = String::from_utf16_lossy(unsafe { std::slice::from_raw_parts(text, (0..).take_while(|&i| *text.add(i) != 0).count()) }); + // SAFETY: frees the string ConvertSidToStringSidW allocated. + unsafe { LocalFree(text.cast()) }; + Ok(sid) +} + /// The user's Local AppData folder as the shell resolves it, the folder the installer uses too; /// for when `LOCALAPPDATA` is missing from the environment. pub fn local_app_data() -> Option { @@ -401,6 +511,40 @@ fn external_allowed(url: &Url) -> bool { mod tests { use url::Url; + #[test] + fn a_portable_data_folder_admits_only_the_user_system_and_administrators() { + use std::os::windows::ffi::OsStrExt; + use windows_sys::Win32::Foundation::LocalFree; + use windows_sys::Win32::Security::Authorization::{GetNamedSecurityInfoW, SE_FILE_OBJECT}; + use windows_sys::Win32::Security::{ACL, DACL_SECURITY_INFORMATION, PSECURITY_DESCRIPTOR}; + let dir = tempfile::tempdir().unwrap(); + let data = dir.path().join("Data"); + let path: Vec = data.as_os_str().encode_wide().chain(Some(0)).collect(); + super::restrict_to_user(&data).unwrap(); + assert!(super::dacl_protected(&path).unwrap(), "inherited permissions no longer apply"); + super::restrict_to_user(&data).unwrap(); + assert!(super::current_user_sid().unwrap().starts_with("S-1-")); + let (mut dacl, mut descriptor): (*mut ACL, PSECURITY_DESCRIPTOR) = (std::ptr::null_mut(), std::ptr::null_mut()); + // SAFETY: `path` is NUL-terminated; on success `descriptor` is a LocalAlloc block freed below and `dacl` points into it. + let status = unsafe { + GetNamedSecurityInfoW( + path.as_ptr(), + SE_FILE_OBJECT, + DACL_SECURITY_INFORMATION, + std::ptr::null_mut(), + std::ptr::null_mut(), + &mut dacl, + std::ptr::null_mut(), + &mut descriptor, + ) + }; + assert_eq!(status, 0); + // SAFETY: `dacl` points into `descriptor`, valid until freed below. + assert_eq!(unsafe { (*dacl).AceCount }, 3, "the user, SYSTEM and Administrators"); + // SAFETY: frees the block GetNamedSecurityInfoW allocated. + unsafe { LocalFree(descriptor) }; + } + #[test] fn local_programs_and_shell_paths_are_refused() { for refused in [ diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index afd37614..4a885f98 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -88,7 +88,7 @@ pub use events::{Event, Protection}; #[cfg(windows)] pub use host_windows::{ Host, MIN_ZOOM, Popup, alert, app_active, bundle_identifier, is_default_browser, local_app_data, make_default_browser, open_external, option_held, - reduce_motion, refresh_browser_registration, reveal_in_finder, shift_held, + reduce_motion, refresh_browser_registration, restrict_to_user, reveal_in_finder, shift_held, }; pub use nav_policy::SiteFor; #[cfg(any(target_os = "macos", windows))] diff --git a/crates/platform/src/updater.rs b/crates/platform/src/updater.rs index 010eb29b..694f361c 100644 --- a/crates/platform/src/updater.rs +++ b/crates/platform/src/updater.rs @@ -66,6 +66,11 @@ pub enum Report { UpToDate, /// Windows: a check asked for, or its download, failed. CheckFailed, + /// Windows, portable: a verified later version, published on `page`. + UpdateAvailable { + version: String, + page: Option, + }, } #[cfg(target_os = "macos")] @@ -236,7 +241,7 @@ mod mac { impl Updater { /// `None` when the bundle carries no valid feed and key or Sparkle does not load. /// `report` hears from Sparkle's delegate on the main thread, inside Sparkle's call. - pub fn start(automatic: bool, nightly: bool, _dir: &std::path::Path, report: impl Fn(Report) + Send + 'static) -> Option { + pub fn start(automatic: bool, nightly: bool, _portable: bool, _dir: &std::path::Path, report: impl Fn(Report) + Send + 'static) -> Option { let mtm = MainThreadMarker::new()?; let bundle = NSBundle::mainBundle(); let info = |key: &str| Some(bundle.objectForInfoDictionaryKey(&NSString::from_str(key))?.downcast::().ok()?.to_string()); diff --git a/crates/platform/src/updater/windows.rs b/crates/platform/src/updater/windows.rs index 8740d0c7..42bc1ea1 100644 --- a/crates/platform/src/updater/windows.rs +++ b/crates/platform/src/updater/windows.rs @@ -97,6 +97,21 @@ fn config(conf: &str) -> Option { Some(Config { feed, nightly_feed, key, downloads }) } +/// The release page of an installer under `config.downloads`, where a portable Tarn's zip is. +fn release_page(config: &Config, installer: &str) -> Option { + let tag = installer.strip_prefix(config.downloads.as_str())?.split('/').next().filter(|t| !t.is_empty() && !t.starts_with('.'))?; + config.downloads.join(&format!("../tag/{tag}")).ok() +} + +/// What a portable Tarn reports for `offer`: each later version once, and again when asked. +fn announce(announced: &mut Option, config: &Config, offer: &Offer, manual: bool) -> Option { + if !manual && announced.as_deref() == Some(offer.version.as_str()) { + return None; + } + *announced = Some(offer.version.clone()); + Some(Report::UpdateAvailable { version: offer.version.clone(), page: release_page(config, &offer.url) }) +} + fn signature(text: &[u8]) -> Result { let bytes = BASE64.decode(text.trim_ascii()).map_err(|_| Refused::BadSignature)?; Signature::from_slice(&bytes).map_err(|_| Refused::BadSignature) @@ -203,12 +218,15 @@ struct Checker { ready: Arc>>, nightly: Arc, report: Box, + /// A portable Tarn only announces a later version: the installer would install elsewhere. + portable: bool, + announced: Option, } impl Checker { /// Wakes hourly and compares wall-clock time, since waits stop while Windows sleeps: a day /// after a check that reached the feed, an hour after one that did not. - fn run(self, mut automatic: bool, messages: mpsc::Receiver) { + fn run(mut self, mut automatic: bool, messages: mpsc::Receiver) { let mut next = SystemTime::now(); if automatic { next += if self.check(false) { DAY } else { HOUR }; @@ -231,7 +249,7 @@ impl Checker { } /// Whether the feed was reached and verified. - fn check(&self, manual: bool) -> bool { + fn check(&mut self, manual: bool) -> bool { let agent = agent(Duration::from_secs(120)); let nightly_feed = self.config.nightly_feed.as_ref().filter(|_| self.nightly.load(Ordering::Relaxed)); let feed_url = nightly_feed.unwrap_or(&self.config.feed).as_str(); @@ -261,6 +279,12 @@ impl Checker { if offer.critical { (self.report)(Report::CriticalFound); } + if self.portable { + if let Some(report) = announce(&mut self.announced, &self.config, &offer, manual) { + (self.report)(report); + } + return true; + } let known = self.ready.lock().ok().and_then(|ready| ready.as_ref().map(|r| r.version == offer.version)); if known == Some(true) { if manual { @@ -326,9 +350,9 @@ pub struct Updater { impl Updater { /// `None` in debug builds and when `packaging/updates.conf` names no valid feed and key. - /// Downloads go into `dir`; folders of versions not newer than this one go first. `report` - /// hears from a background thread. - pub fn start(automatic: bool, nightly: bool, dir: &Path, report: impl Fn(Report) + Send + 'static) -> Option { + /// Downloads go into `dir`; folders of versions not newer than this one go first. A `portable` + /// Tarn downloads nothing and reports `UpdateAvailable`. `report` hears from a background thread. + pub fn start(automatic: bool, nightly: bool, portable: bool, dir: &Path, report: impl Fn(Report) + Send + 'static) -> Option { if cfg!(debug_assertions) || !dir.is_absolute() { return None; } @@ -342,7 +366,8 @@ impl Updater { let (messages, receiver) = mpsc::channel(); let ready = Arc::new(Mutex::new(None)); let nightly = Arc::new(AtomicBool::new(nightly)); - let checker = Checker { config, dir: dir.to_owned(), ready: ready.clone(), nightly: nightly.clone(), report: Box::new(report) }; + let checker = + Checker { config, dir: dir.to_owned(), ready: ready.clone(), nightly: nightly.clone(), report: Box::new(report), portable, announced: None }; std::thread::Builder::new().name("tarn-updater".into()).spawn(move || checker.run(automatic, receiver)).ok()?; Some(Updater { messages, nightly, ready, install: std::cell::Cell::new(false), automatic: std::cell::Cell::new(automatic) }) } @@ -467,6 +492,30 @@ mod tests { assert!(config("").is_none()); } + #[test] + fn a_portable_tarn_links_the_release_page_of_the_offer() { + let config = test_config(); + let page = |installer: &str| release_page(&config, installer).map(String::from); + assert_eq!(page(&url("9.0.0")).as_deref(), Some("https://github.com/Quavon-dev/tarn-browser/releases/tag/v9.0.0")); + assert_eq!( + page("https://github.com/Quavon-dev/tarn-browser/releases/download/nightly/Tarn-setup.exe").as_deref(), + Some("https://github.com/Quavon-dev/tarn-browser/releases/tag/nightly") + ); + assert_eq!(page("https://github.com/Quavon-dev/tarn-browser/releases/download/../x.exe"), None); + assert_eq!(page("https://example.com/v9.0.0/x.exe"), None); + } + + #[test] + fn a_portable_tarn_announces_each_later_version_once_unless_asked() { + let config = test_config(); + let offer = check(&feed_json("9.0.0", false, &url("9.0.0"), &sha256_hex(INSTALLER)), "0.4.0").unwrap().offer.unwrap(); + let page = Some(Url::parse("https://github.com/Quavon-dev/tarn-browser/releases/tag/v9.0.0").unwrap()); + let mut announced = None; + assert_eq!(announce(&mut announced, &config, &offer, false), Some(Report::UpdateAvailable { version: "9.0.0".into(), page: page.clone() })); + assert_eq!(announce(&mut announced, &config, &offer, false), None); + assert_eq!(announce(&mut announced, &config, &offer, true), Some(Report::UpdateAvailable { version: "9.0.0".into(), page })); + } + #[test] fn a_signed_later_version_is_offered() { let checked = check(&feed_json("9.0.0", true, &url("9.0.0"), &sha256_hex(INSTALLER)), "0.4.0").unwrap(); diff --git a/docs/mobile-plan.md b/docs/mobile-plan.md index e65d3540..36fc0f61 100644 --- a/docs/mobile-plan.md +++ b/docs/mobile-plan.md @@ -839,6 +839,13 @@ the simulator's keychain; evidence in `mobile/evidence/themes-github/`. Android carries theme sheets in the page world, as it does site CSS (S28/S29). +### Install script and portable build + +Not on iOS or Android, a platform gap: apps come from the stores (or a sideloaded APK) and run only +once installed, so the Homebrew cask, `install.ps1` and the portable zip (`docs/release.md`) have no +counterpart. The phone hosts pass their own data folder, so `browser_core::portable_dir` never +applies there. + ### Nightly builds Not on iOS or Android, a platform gap: the stores decide which build a phone installs, so Settings › diff --git a/docs/port-backlog.md b/docs/port-backlog.md index d819030e..45c7d790 100644 --- a/docs/port-backlog.md +++ b/docs/port-backlog.md @@ -21,6 +21,21 @@ Reference: . ## Open +### Portable download (2026-11-24) + +What it does: a download that runs without installing and keeps all its data in a `Data` folder +beside the executable, with a command-line install for the regular build. +Shared API: `browser_core::portable_dir` (a `tarn-portable` file beside the executable), used by +`browser_core::data_dir`; Windows only so far. +Reference: `.github/workflows/release.yml` (`windows` job, portable zip; `assets` job, +`install.ps1`), `crates/platform/src/updater/windows.rs` (portable updater), `packaging/homebrew/`. + +- [ ] Linux — turn `portable_dir` on for Linux, refusing a folder the user does not own or others + can write (a marker in `/tmp` would take a victim's profile); key `single_instance` + (`linux/src/main.rs`) on the data folder as Windows does; and build a release archive (AppImage or + tarball with `tarn-portable`) in `linux/packaging/build-all.sh`, which needs WebKitGTK 6 from the + distribution or bundles it. + ### Hand freed memory back to the system (2026-11-24) What it does: once a minute, after tabs closed or slept, and once when Tarn leaves the front, the diff --git a/docs/release.md b/docs/release.md index 2e2be2bd..43c3159e 100644 --- a/docs/release.md +++ b/docs/release.md @@ -22,6 +22,11 @@ feeds ("Signing in CI") and publishes a GitHub release with: `Tarn--windows-x64-setup-unsigned.exe`, the Inno Setup installer of the same folder (`scripts/installer-windows.sh`, Inno Setup pinned by version and SHA-256 in the workflow), which users install and the updater downloads. `windows-update.json` and `.sig`, the signed Windows feed. + `Tarn--windows-x64-portable-unsigned.zip`: the same folder with a `tarn-portable` file beside + `tarn.exe`, which runs without installing and keeps its data in `Data` there + (`browser_core::portable_dir`). `install.ps1`, which the `assets` job fills in from + `packaging/windows/install.ps1` (text substitution only): it names this release's installer and + portable zip with their SHA-256 and refuses a download that differs. - `tarn___amd64.deb` (Debian, Ubuntu), the Fedora `.rpm` and the Arch `.pkg.tar.zst`, each built in a clean container by `linux/packaging/build-all.sh`. - `Tarn--ios-unsigned.zip` (`nsh package --target ios`, built with Xcode 26.3 and the iOS 26 SDK; the bundle @@ -59,9 +64,11 @@ packages, Gradle dependencies and, on Arch, Rust from the distribution without a are pinned by digest and rustup-init by SHA-256). The `sbom` job only writes the SBOMs. The `deny` job runs `cargo deny check` (advisories, bans, licences, sources) on every workspace of the released commit, engine updates included, and `sign` waits for it (`SECURITY.md`, "Dependency and code -scanning"). The `assets` job, which runs no build code, downloads each artifact by the ID its build -job reported and accepts only that job's own file names, so no job can replace another platform's -file; it writes `SHA256SUMS` and attests every binary (the macOS archives included), the SBOMs and +scanning"). The `assets` job, which runs no build code, downloads each artifact by the ID its +build job reported and accepts only that job's own file names, so no job can replace another +platform's file; it fills the placeholders of `packaging/windows/install.ps1` with the Windows +installer and portable zip it took and their SHA-256 (`sed`, no script from the repository), writes +`SHA256SUMS` and attests every binary (the macOS archives included), the SBOMs, `install.ps1` and `SHA256SUMS` itself. The archives are attested (`actions/attest`, predicate type @@ -120,8 +127,9 @@ and: The `assets` job takes the signed files with the rest, writes `SHA256SUMS` and attests them, and `publish` publishes the release, marks the highest published version as the latest release (an older one finishing late never takes over the feeds), gives that release the newest signed Windows feed of -the recent releases (a macOS-only release carries the feed that was latest when it started), and -starts `linux-repo.yml`. It does so holding the branch `release-latest-lock`, which it deletes +the recent releases (a macOS-only release carries the feed and `install.ps1` that were latest when +it started; a newer feed brings its release's `install.ps1` along), and starts `linux-repo.yml`; +the `homebrew` job then updates the cask ("Homebrew"). It does so holding the branch `release-latest-lock`, which it deletes afterwards; delete it by hand only if a cancelled run left it behind, then re-run that run's `publish`, which finishes a release it had already created. A tag whose message has the line `critical` marks both feeds critical. @@ -282,12 +290,36 @@ every release carries all three files. An engine update (`chromium-update.yml`) macOS-only run builds no Windows files; its `publish` job carries the latest release's `windows-update.json` and `.sig` over unchanged (they are not in that release's `SHA256SUMS`, which the `assets` job wrote before; their Ed25519 signature covers them), which stay valid, so Windows keeps a verified feed; without them Windows checks fail: new installs open no page, and existing ones close Chromium seven days after their last -verified check. Windows still needs its own release within 28 days of +verified check. The same step carries the latest release's `install.ps1` over, which still names +that release's Windows files by tag and SHA-256, so the install command keeps working (it is +attested with that release, not in this release's `SHA256SUMS`); when +`publish` gives the latest release a newer Windows feed, it copies that release's `install.ps1` +along, unless the latest release's names a newer tag. Either way the script must first match the +`SHA256SUMS` attested for the tag it names, by `release.yml` run from that tag or `main` on a +GitHub-hosted runner (`scripts/attestation.sh`). Windows still needs its own release within 28 days of each Chromium update, since the staleness gate also closes Chromium by its age. `scripts/sign-windows.ps1 -Check` checks a release feed by hand; the authority is the client's own verification (`crates/platform/src/updater/windows.rs`). `scripts/sign-windows.test.ps1` (run by the `windows` CI job) checks the Ed25519 verification against RFC 8032's test vectors and the feed format. +## Homebrew + +`brew install --cask quavon-dev/tarn/tarn` reads `Casks/tarn.rb` in the tap repository +`Quavon-dev/homebrew-tarn`. After `publish`, `release.yml`'s `homebrew` job renders the cask from +`packaging/homebrew/tarn.rb.in` (`scripts/homebrew-cask.sh`) with the disk image's SHA-256 from the +attested `SHA256SUMS`, and pushes it to the tap; it always names the latest release, so a run +replaced in the job's queue loses nothing (never a nightly). The cask sets `auto_updates true`, so Sparkle keeps updating the app and +`brew upgrade` leaves it alone. Setup, once, by a maintainer: + +1. Create the public repository `Quavon-dev/homebrew-tarn` with one commit on its default branch. +2. Add a deploy key with write access there (`ssh-keygen -t ed25519 -N ''`), and nowhere else. +3. Create the `homebrew-tap` environment here (deployments from `v*` tags and `main`) holding the + private key as `HOMEBREW_TAP_DEPLOY_KEY`. + +Without the secret the job notes that the cask was not updated and succeeds. Until the tap exists, +`scripts/homebrew-cask.sh Quavon-dev/tarn-browser` prints the cask for a manual +commit. + ## Store submission (protected CI) `mobile-store.yml` signs published stable releases for TestFlight and Google Play internal testing. @@ -475,21 +507,23 @@ Applied by hand in the repository and organisation settings; no workflow changes - **Stored** only as secrets of the GitHub environments named above (`release-signing`, `nightly-signing`, `chromium-update`, `filter-signing`) and of `linux-repo` and `aur` - (`linux-repo.yml`), never as repository secrets, in the repository, in workflow files or in logs. + (`linux-repo.yml`) and `homebrew-tap` (`release.yml`), never as repository secrets, in the repository, in workflow files or in logs. Mobile store keys live only in the separate `ios-store` and `android-store` environments; build, release assembly and nightly jobs hold none of them. - **Accessed** only by the one job that needs each one: `sign` for the Apple and notary credentials and the update key (`SPARKLE_ED_PRIVATE_KEY`, which signs both the Sparkle feed and the Windows feed); the `open` and `tag` jobs of `chromium-update.yml` and `sign` for the update app key; the signing job of `filter-lists.yml` for `FILTER_SIGNING_KEY`; the `build` job of `linux-repo.yml` for - `LINUX_REPO_GPG_KEY` and `LINUX_REPO_GPG_PASSPHRASE`, its `aur` job for `AUR_SSH_PRIVATE_KEY`. + `LINUX_REPO_GPG_KEY` and `LINUX_REPO_GPG_PASSPHRASE`, its `aur` job for `AUR_SSH_PRIVATE_KEY`; + the `homebrew` job of `release.yml` for `HOMEBREW_TAP_DEPLOY_KEY`. `release-signing` needs a maintainer's approval for every run; a maintainer may approve their own release. `nightly-signing` holds the same Apple credentials and update key without approval, but only `main` may deploy to it. Maintainers with admin rights can set secrets but cannot read them back. - **Rotated** at once when a secret may have leaked, when a maintainer with access to it leaves, or when a workflow that reads it was compromised; otherwise the Developer ID certificate when it - expires, and the notary API key, the update app's private key and the AUR SSH key every year. + expires, and the notary API key, the update app's private key, the AUR SSH key and the tap's + deploy key every year. Replacing the update key (both updaters) or the filter signing key also needs an app release carrying the new public key before the old key is retired, so installed apps keep verifying updates; a new apt/dnf repository key is published in the repository and announced in the release diff --git a/docs/shared-core.md b/docs/shared-core.md index 4ba84243..2e3f5374 100644 --- a/docs/shared-core.md +++ b/docs/shared-core.md @@ -323,9 +323,13 @@ rule-list type); `engine::DataStore` implements it on macOS and the GPUI shell n `Core`. Each NSH shell implements it for its own web view's data store. Its ephemeral store holds the private space and Lockdown data and must never write website data to disk (threat model S8); each implementation needs a test that checks this on its platform. `data_dir(base)` -is `TARN_DATA_DIR`, else the host's `base`, else `~/Library/Application Support/Tarn` on macOS and -`$XDG_DATA_HOME/tarn` or `~/.local/share/tarn` on Linux; iOS and Android have no default, so their -host passes `base`. `container` and `staleness` are macOS-only. +is `TARN_DATA_DIR`, else the host's `base`, else `Data` beside the executable when a +`tarn-portable` file sits there (`portable_dir`, Windows only, decided once per run), else +`~/Library/Application Support/Tarn` on macOS and `$XDG_DATA_HOME/tarn` or `~/.local/share/tarn` +on Linux; iOS and Android have no default, so their host passes `base`. macOS has no portable mode, +a platform gap: WebKit keeps site data under `~/Library/WebKit` and secrets go to the Keychain, +outside any folder Tarn could carry along; the app bundle itself runs from any folder. Linux has +none yet (`docs/port-backlog.md`). `container` and `staleness` are macOS-only. **Window model:** `browser_core::tabs::Model` holds one window's spaces, the current space's tabs, folders and groups, the open folders, the active tab, the tab lifecycle and the diff --git a/docs/threat-model.md b/docs/threat-model.md index 9c54ffaa..4ba5db80 100644 --- a/docs/threat-model.md +++ b/docs/threat-model.md @@ -12,13 +12,13 @@ settings per client are in `cryptography.md`; the actors, components and externa | S17 | Critical | Page text injects instructions into the Claude CLI, which can run commands and read files | Helper runs the CLI with tools and MCP disabled, fixed arguments, no shell, prompt on stdin, minimal environment, empty temporary working directory, timeout and output cap. Binary path is absolute, chosen by the user, and must not be world-writable. The helper accepts connections only from our signed app. If tool disabling cannot be confirmed, the provider refuses to run. | `tarn-cli-bridge` enforces the CLI rules: fixed arguments, `--help` probe, stdin prompt, only `HOME` and `PATH=/usr/bin:/bin`, own process group killed when the run ends or times out, and the binary plus every ancestor directory owned by the user or root and writable only by them, `wheel` or `admin`. Cancelling in the app stops the bridge, not the CLI it started. Not reachable from the packaged app only because `scripts/bundle.sh` does not ship the helper: the app runs without the App Sandbox, so a child would no longer inherit one. The XPC helper and its caller check are not built. An npm-installed CLI (`#!/usr/bin/env node`) does not start with that `PATH`. | | S2 | High | Prompt injection makes the AI leak data or act | The model has no tools in any provider. Output is rendered natively as text: no remote images, no auto-opened links. Grouping returns schema-validated JSON limited to the tab IDs sent and is applied after confirmation. Context is limited to the active profile; query strings are stripped from URLs. | Linux, iOS and Android draw the chat from `browser_core::assistant::view` with `tarn_nsh_shared::assistant`: answers are drawn natively from `ai::markdown` (images as alt text, HTML as text), and a link opens only through `links::classify` and a confirmation that shows the whole address, a web link in a new tab of the chat's profile; Clean Up's Group with Assistant checks the answer with `ai::grouping::parse` against the tabs it sent and files them only after a confirmation, undoably (`a_grouping_answer_is_checked_against_the_tabs_sent`, `the_assistant_groups_only_what_it_was_sent_and_undo_takes_it_back`); the chat ends once the window shows another profile, a private space, a burner tab, a Lockdown page or AI turned off, checked on every change and again after a link's confirmation, so a link opens only in the chat's own profile (`the_chat_ends_once_the_window_shows_another_profile_or_a_space_it_may_not_see`), and a page's text is read for a pill only where the assistant may see it. On every client a grouping is shown and applied only while the space it was asked in is current with the assistant allowed (`sidebar::grouping_here`), and group names lose control, bidi and invisible characters (`names_lose_bidi_and_zero_width_characters`); macOS and Windows stop the grouping request when the window closes or its answer passes `MAX_OUTPUT_BYTES`. A selection or a tab's text reaches the chat only with the address it was read from, and every client drops it once the tab no longer shows that address (`assistant::read_here`: `text_counts_only_from_the_address_its_tab_shows_now`; macOS and Windows read it with `page_scripts::with_address`); a tab is read for a pill only where `assistant_offered` allows its address (`a_selection_and_a_loaded_tab_reach_the_assistant_and_a_sleeping_tab_is_never_read` on Linux, iOS and Android). On Android the selection is read in the page's own world (see "Page scripts on Android"), so the page can forge it: it is treated as untrusted page content like page text, bounded by `page_ops::selection` and sent as a data block, never as instructions. macOS and Windows (`crates/app/src/assistant.rs`) draw answers natively with `ai::markdown` (no images, every link with its whole address shown), open a link only through `assistant::links` and a confirmation naming its host and address, and sort tabs only after a confirmation listing each proposed group. The core rules in `browser_core::assistant`: query strings, fragments and sign-in parts stripped (`urls_lose_query_fragment_and_sign_in_and_text_loses_control_and_bidi`), templates expanded once (`a_placeholder_inside_page_text_or_the_question_stays_literal`), no text can open or close a block: each request's block tag holds a random nonce of its own and `tarn-block` is removed whatever its case or the invisible characters inside it (`no_text_can_open_or_close_a_block`, `invisible_characters_and_case_folding_cannot_hide_a_block_tag`), every link opens only after a confirmation that shows the whole address, `mailto` loses its headers and is refused when its address encodes `?`, `&`, a control or an invisible character, local and home-network hosts and other schemes are refused (`web_links_and_mail_open_only_after_a_confirmation`, `link_text_never_replaces_the_address`), answers stop at their size limit (`an_answer_stops_at_its_size_limit`), cancelled, failed or empty exchanges are never sent again (`cancel_drops_an_empty_answer_and_marks_a_partial_one`, `an_answer_that_ends_empty_counts_as_interrupted`), pills only from the chat's profile (`pills_from_private_burner_lockdown_or_another_profile_are_refused`); tab grouping sends only the id, host and title of loose web tabs, never local files, home-network pages or Lockdown pages, and files only tabs it sent (`browser_core::cleanup::ai`: `local_files_and_home_network_pages_are_never_sent`, `only_tabs_that_were_sent_can_be_filed`). A selection command's answer goes only to the chat, never into the page; the answer's links are also listed as keyboard stops under it (macOS and Windows tab stops, NSH buttons) that open through the same `links::classify` confirmation. | | S3 | High | API token or page content leaks | Token only in the platform secret store (Keychain, Credential Manager, Secret Service, Android Keystore). Content leaves the device only after an explicit click with a visible indicator. AI is unavailable in the private profile. We never read the CLI's stored credentials. | `ai::Secrets` keeps the API token in the platform store only, with no fallback to a file: the Keychain on macOS and iOS, the Credential Manager on Windows and the Secret Service on Linux (`ai::secrets::Keyring`); on Android it is sealed with AES-GCM under a key that never leaves the Android Keystore (`tarn_mobile_android::Keystore`, `Secrets.java`). `ApiToken`'s `Debug` never shows the value (`token_never_in_debug_output`). On Linux, iOS and Android (`tarn_nsh_shared::assistant`) a request leaves only on Send, a command or Group with Assistant, the chat lists every block a send carries with its size first, Settings › AI and the chat are hidden or refused in a private space, a burner tab and at Lockdown (`tabs::Model::assistant_origin` carries the page's own Shield level: `the_assistant_origin_carries_the_kind_and_the_sites_own_level`), the key typed into Settings › AI goes straight to the platform store, a Claude request without a stored key sends nothing and Ollama never gets the key (`claude_needs_a_stored_key_and_sends_it_only_to_anthropic`, `ollama_answers_on_loopback_without_the_key`), and a build for neither phone has no store and sends nothing; turning the switch off, deleting a profile or clearing its data drops every window's chat. macOS and Windows the assistant column (`crates/app/src/assistant.rs`) sends only on Send, names every block a send carries with its size above the question field, passes the active page's effective Shield level (per-site setting included) with each send, drops the chat when the profile, its data or its AI switch goes, and shows no chat in a private space, burner tab or Lockdown; Settings › AI stores the key through `ai::secrets::Keyring` only.. The core rules in `browser_core::assistant`: no chat in a private space, burner tab, Lockdown or with the profile's AI switch off (`private_burner_and_lockdown_get_no_session`), a send from any of them, from another profile or with the switch off is refused and drops every pill, and a pill whose page went to Lockdown since it was added, or whose address does not parse, is dropped, also after the user removed it, and the answers given while it or a refused send's pills were attached are never sent again (`a_refused_send_forgets_answers_given_while_its_pills_were_attached`, `a_removed_pill_whose_page_went_to_lockdown_still_forgets_its_answers`, `a_send_from_where_the_assistant_is_not_allowed_is_refused_and_drops_the_pills`, `a_send_drops_pills_whose_page_went_to_lockdown_since_they_were_added`, `a_pill_without_a_readable_address_counts_as_lockdown`, `answers_given_while_a_pill_now_in_lockdown_was_attached_are_never_sent_again`), nothing is sent without a send event and every block it would carry is listed with its size (`the_view_lists_every_block_that_would_be_sent`), each block and the whole request are capped (`pills_are_capped_each_and_with_history_in_total`). Local models implement `ai::LocalModel` and run only through `ai::local::stream`, the one place that can make the `local::Checked` token their `respond` takes, after their availability check: `engine::foundation_models::FoundationModel` (macOS and iOS, the `foundation-models` feature) calls only `SystemLanguageModel.default` and takes no transport; `ai::Ollama` is available only when Ollama on loopback answers `/api/show` for the model and reports no remote host, and a `-cloud` or `:cloud` name is refused before anything is asked (`cloud_models_are_never_local`, `an_ollama_that_does_not_answer_needs_setup_and_gets_no_question`). An unavailable model answers `AiError::Unavailable` with its reason instead of another model answering; `ai::local::route` never sends a local choice to the cloud (`a_local_choice_never_routes_to_the_cloud`). A selection or another tab reaches the assistant only by the user's choice: the selection menu has no assistant entry where `tabs::Model::assistant_menu` refuses the page (AI off, private space, burner, Lockdown), the tab picker lists only the current space's other web tabs the assistant may read and never wakes a sleeping one to read it (`the_tab_picker_lists_other_web_tabs_the_assistant_may_read_and_wakes_none`, `a_selection_and_a_loaded_tab_reach_the_assistant_and_a_sleeping_tab_is_never_read` on Linux and mobile), and a send still checks every pill's page level. Commands run on the system's on-device model when it is available and the cloud was chosen; with a local choice that cannot answer the chat says why and asks no cloud, and every answer names the model that gave it (`ai::local::answer`: `commands_stay_on_the_device_when_it_can_answer_and_say_who_answered`; `commands_answer_on_the_device_and_name_it_while_questions_go_where_chosen`). | -| S4 | High | Malicious update | EdDSA-signed updates, HTTPS, downgrade protection, signing keys only in the signing environments of the release workflow. On Windows, `platform::updater` reads `windows-update.json` next to the appcast: its Ed25519 signature (the Sparkle key in `packaging/updates.conf`, compiled in) is checked over the exact bytes before anything is parsed; the installer must come over https from this repository's release downloads, match the signed length, SHA-256 and its own Ed25519 signature before it is written, and is hashed again through a handle that bars writes while it starts; only a later version is offered; feeds are capped at 64 KiB and installers at 512 MiB. Windows releases ship the unsigned installer CI built: the release workflow's signing job, which runs no build code, signs that run's installer and its `windows-update.json` with the update key (`scripts/windows-feed.sh`, its URL limited to this repository's release downloads), so installs have no Authenticode signature; `scripts/sign-windows.ps1` (Authenticode) is not part of CI and no certificate is set up. Remaining on Windows: the installer is not Authenticode-checked by the updater, so the Ed25519 key is the only anchor, and a replayed feed that lists the running version still counts as a verified check (as on macOS) until releases carry an expiry. Repository: two-factor login, branch protection, pinned actions, no secrets for fork pull requests. | CI actions pinned by commit hash; no job that pull requests, issues or comments can start runs on a self-hosted runner: enforced only by the runner group's "Selected workflows" limit and fork-approval settings in `release.md`, applied by hand, since a fork pull request runs its own edited workflow; `scripts/check-workflows.sh` in CI is a merge-time lint that keeps such jobs out of `main`, not a control on what a pull request can schedule; `.github/CODEOWNERS` covers the workflows, `codesign-app.sh`, `bundle.sh`, `packaging/`, the lockfiles and manifests and the embedded signing keys (owner `@Quavon-dev/maintainers`), and `main`'s ruleset requires approval of the most recent push and dismisses stale approvals (settings by hand) but does not require an up-to-date branch, so a merge can land a tree CI did not test; Chromium updates are proposed by `chromium-update.yml` as pull requests that run CI and need a maintainer's approval like any other; once merged, it tags them (except one that moves the `cef` crate, which a maintainer releases) and `release.yml` signs and publishes them only after a maintainer approves its `release-signing` deployment. Updater: Sparkle 2.10.1, pinned by SHA-256, verifies the archive's EdDSA signature before extraction, requires a signed feed and refuses older versions; the feed (the latest published GitHub release's `appcast.xml`) and the public key are in `packaging/updates.conf` and only release bundles carry them; the private key, the Developer ID certificate and the notary API key are secrets of the `release-signing` environment (deployments from `main` and `v*` tags, a maintainer's approval) and the `nightly-signing` environment (deployments from `main` only, no approval) and the private key has an offline backup; only the `sign` job enters them, runs no build code, imports the certificate into a temporary keychain and writes the other keys under `RUNNER_TEMP`, and deletes both when it ends. A compromised build job or dependency build script holds none of them, but a workflow or script changed on `main` runs with them on the next nightly without approval and could sign a feed that Release users accept, since both channels share the update key (Sparkle takes one `SUPublicEDKey`); code-owner review of `.github/` and `scripts/` on `main` is what stands in the way, and `scripts/appcast.sh` signs only a notarised Tarn of team CFV35FGSHF whose version matches the tag. The feed URL comes from Info.plist through the updater delegate, never from user defaults; with Settings › General › Nightly builds on it is the same file in the `nightly` release (`platform::updater::nightly_feed`), on macOS and Windows. Nightly builds carry `.` versions and are signed with the same keys: every commit merged to `main`, including engine updates (reviewed, with a CEF archive whose hash only `chromium-update.yml`'s own download checked), reaches users of that channel signed and notarised within a day, with no release review. Nightly feeds carry their channel inside the signed bytes (`sparkle:channel`, the Windows feed's `channel`), and the Release channel refuses them, so a nightly feed uploaded to a release is not offered to Release users. A nightly on the Release channel counts the release feed as current for its release version (`channel_version`) and is offered only a later release. A check counts as verified for the Chromium staleness gate only if the signed appcast lists the running version or a later one, so an old appcast replayed through a release asset no longer keeps Chromium open; one listing the running version still does. A feed that fails verification still offers items in Sparkle's fallback mode (no critical marking); the archive signature still applies. Tampered and older updates not yet tried against a real feed. Windows, Linux and mobile release files are built unsigned from pinned containers and a pinned rustup-init but with unpinned distribution packages and Gradle dependencies; they are attested by a job that runs none of their code, and each build job can add only its own file names to the release. A release run starts from a `v*` tag push (tag creation limited by ruleset), from `start-release.yml` on `main` (any account with write access can start it; it builds every client without keys, and only after a maintainer approves the `release-signing` deployment does the `sign` job create the `v*` tag with the update app, whose key that environment then also holds, so this tag is the app's, not a maintainer's signed tag), a manual `workflow_dispatch` on an existing `v*` tag, which any account with write access can start and which builds macOS alone, or `chromium-update.yml`; it never replaces a published release's files (a re-run of a published tag only marks the highest version latest) and publishes only after the `release-signing` deployment is approved. `nightly.yml` publishes the `nightly` pre-release without approval. The signed zip, disk image and feeds are in `SHA256SUMS` and the attestation. Mobile stores: only `mobile-store.yml` dispatched on `main` enters the separately approved `ios-store` and `android-store` environments. Each runner verifies the published stable release, attested `SHA256SUMS` and its mobile artifact with the release workflow identity, rejects self-hosted provenance, and binds the verified predicate to the current tag commit before exposing signing secrets to a step. Released code is never executed, and credential jobs build nothing or install dependencies. iOS validates the distribution profile, bundle identity/version and permitted signing certificate; ZIP links, traversal and nested code are rejected. Android signs only the AAB with a separate Play upload key and uses GitHub OIDC restricted to this repository, `main`, the store environment and workflow for short-lived Google tokens; Play retains the app signing key. Uploads go only to TestFlight and Play internal testing (draft by default), never a production track or explicit public submission. Play commits fail when an existing review is pending and request review deferral after rejection; required internal-release reviews remain a Console step. Temporary keys and signed bundles are deleted and never become GitHub artifacts. Code-owner review of the trusted workflow and signing script remains essential; compromise of either store environment can publish internal builds for its app. | +| S4 | High | Malicious update | EdDSA-signed updates, HTTPS, downgrade protection, signing keys only in the signing environments of the release workflow. On Windows, `platform::updater` reads `windows-update.json` next to the appcast: its Ed25519 signature (the Sparkle key in `packaging/updates.conf`, compiled in) is checked over the exact bytes before anything is parsed; the installer must come over https from this repository's release downloads, match the signed length, SHA-256 and its own Ed25519 signature before it is written, and is hashed again through a handle that bars writes while it starts; only a later version is offered; feeds are capped at 64 KiB and installers at 512 MiB. Windows releases ship the unsigned installer CI built: the release workflow's signing job, which runs no build code, signs that run's installer and its `windows-update.json` with the update key (`scripts/windows-feed.sh`, its URL limited to this repository's release downloads), so installs have no Authenticode signature; `scripts/sign-windows.ps1` (Authenticode) is not part of CI and no certificate is set up. Remaining on Windows: the installer is not Authenticode-checked by the updater, so the Ed25519 key is the only anchor, and a replayed feed that lists the running version still counts as a verified check (as on macOS) until releases carry an expiry. Repository: two-factor login, branch protection, pinned actions, no secrets for fork pull requests. | CI actions pinned by commit hash; no job that pull requests, issues or comments can start runs on a self-hosted runner: enforced only by the runner group's "Selected workflows" limit and fork-approval settings in `release.md`, applied by hand, since a fork pull request runs its own edited workflow; `scripts/check-workflows.sh` in CI is a merge-time lint that keeps such jobs out of `main`, not a control on what a pull request can schedule; `.github/CODEOWNERS` covers the workflows, `codesign-app.sh`, `bundle.sh`, `packaging/`, the lockfiles and manifests and the embedded signing keys (owner `@Quavon-dev/maintainers`), and `main`'s ruleset requires approval of the most recent push and dismisses stale approvals (settings by hand) but does not require an up-to-date branch, so a merge can land a tree CI did not test; Chromium updates are proposed by `chromium-update.yml` as pull requests that run CI and need a maintainer's approval like any other; once merged, it tags them (except one that moves the `cef` crate, which a maintainer releases) and `release.yml` signs and publishes them only after a maintainer approves its `release-signing` deployment. Updater: Sparkle 2.10.1, pinned by SHA-256, verifies the archive's EdDSA signature before extraction, requires a signed feed and refuses older versions; the feed (the latest published GitHub release's `appcast.xml`) and the public key are in `packaging/updates.conf` and only release bundles carry them; the private key, the Developer ID certificate and the notary API key are secrets of the `release-signing` environment (deployments from `main` and `v*` tags, a maintainer's approval) and the `nightly-signing` environment (deployments from `main` only, no approval) and the private key has an offline backup; only the `sign` job enters them, runs no build code, imports the certificate into a temporary keychain and writes the other keys under `RUNNER_TEMP`, and deletes both when it ends. A compromised build job or dependency build script holds none of them, but a workflow or script changed on `main` runs with them on the next nightly without approval and could sign a feed that Release users accept, since both channels share the update key (Sparkle takes one `SUPublicEDKey`); code-owner review of `.github/` and `scripts/` on `main` is what stands in the way, and `scripts/appcast.sh` signs only a notarised Tarn of team CFV35FGSHF whose version matches the tag. The feed URL comes from Info.plist through the updater delegate, never from user defaults; with Settings › General › Nightly builds on it is the same file in the `nightly` release (`platform::updater::nightly_feed`), on macOS and Windows. Nightly builds carry `.` versions and are signed with the same keys: every commit merged to `main`, including engine updates (reviewed, with a CEF archive whose hash only `chromium-update.yml`'s own download checked), reaches users of that channel signed and notarised within a day, with no release review. Nightly feeds carry their channel inside the signed bytes (`sparkle:channel`, the Windows feed's `channel`), and the Release channel refuses them, so a nightly feed uploaded to a release is not offered to Release users. A nightly on the Release channel counts the release feed as current for its release version (`channel_version`) and is offered only a later release. A check counts as verified for the Chromium staleness gate only if the signed appcast lists the running version or a later one, so an old appcast replayed through a release asset no longer keeps Chromium open; one listing the running version still does. A feed that fails verification still offers items in Sparkle's fallback mode (no critical marking); the archive signature still applies. Tampered and older updates not yet tried against a real feed. Windows, Linux and mobile release files are built unsigned from pinned containers and a pinned rustup-init but with unpinned distribution packages and Gradle dependencies; they are attested by a job that runs none of their code, and each build job can add only its own file names to the release. A release run starts from a `v*` tag push (tag creation limited by ruleset), from `start-release.yml` on `main` (any account with write access can start it; it builds every client without keys, and only after a maintainer approves the `release-signing` deployment does the `sign` job create the `v*` tag with the update app, whose key that environment then also holds, so this tag is the app's, not a maintainer's signed tag), a manual `workflow_dispatch` on an existing `v*` tag, which any account with write access can start and which builds macOS alone, or `chromium-update.yml`; it never replaces a published release's files (a re-run of a published tag only marks the highest version latest) and publishes only after the `release-signing` deployment is approved. `nightly.yml` publishes the `nightly` pre-release without approval. The signed zip, disk image and feeds are in `SHA256SUMS` and the attestation. Mobile stores: only `mobile-store.yml` dispatched on `main` enters the separately approved `ios-store` and `android-store` environments. Each runner verifies the published stable release, attested `SHA256SUMS` and its mobile artifact with the release workflow identity, rejects self-hosted provenance, and binds the verified predicate to the current tag commit before exposing signing secrets to a step. Released code is never executed, and credential jobs build nothing or install dependencies. iOS validates the distribution profile, bundle identity/version and permitted signing certificate; ZIP links, traversal and nested code are rejected. Android signs only the AAB with a separate Play upload key and uses GitHub OIDC restricted to this repository, `main`, the store environment and workflow for short-lived Google tokens; Play retains the app signing key. Uploads go only to TestFlight and Play internal testing (draft by default), never a production track or explicit public submission. Play commits fail when an existing review is pending and request review deferral after rejection; required internal-release reviews remain a Console step. Temporary keys and signed bundles are deleted and never become GitHub artifacts. Code-owner review of the trusted workflow and signing script remains essential; compromise of either store environment can publish internal builds for its app. Install channels: the `assets` job, which runs no build code, writes `install.ps1` by filling the placeholders of `packaging/windows/install.ps1` with the installer and portable zip it took and their SHA-256 (text substitution, no repository script); it is in `SHA256SUMS` and the attestation, downloads only from this repository's release of its tag and refuses a file whose SHA-256 differs from the one written into it. Its anchor is GitHub's TLS and the release workflow, as for a browser download, but `irm \| iex` gives the unsigned installer no mark of the web, so SmartScreen does not check it. A macOS-only release carries the previous `install.ps1` over unchanged, outside its own `SHA256SUMS`, as it does the Windows feed; before `publish` puts one on the latest release, carried or copied, it must match the `SHA256SUMS` attested for the tag the script names, by `release.yml` run from that tag or `main` on a GitHub-hosted runner (`scripts/attestation.sh`), and a copy never replaces a script that names a newer release. The Homebrew cask always names the latest release and pins its disk image's SHA-256 from that release's `SHA256SUMS`, attested the same way; the `homebrew` job pushes it, one run at a time, with a deploy key that can write only to the tap repository, a secret of the `homebrew-tap` environment given only to the push step, and Sparkle's signature check still applies to every later update. A portable Windows Tarn (`browser_core::portable_dir`) checks the same signed feed but downloads and starts no installer; it stays on its version until the user replaces it, and the Chromium staleness gate closes its Chromium tabs as on every install. | | S18 | High | Malicious or compromised extension | Per-profile install, per-site permission prompts, hash recorded, no silent updates, off in private mode by default, no access to internal pages or other profiles. | App and Official extensions get every site they list without a prompt while Settings › Extensions › "Allow extensions on every site" is on, which is the default (`Pref::ExtensionsEverySite`); Unverified ones always ask per site and Lockdown hosts stay denied. `tabs.create` from an App extension opens a web page as a normal tab through `nav_policy`, at the pop-up rate (3 in 10 s) and never with a private-network address as its URL (S10). Open: that tab is a user load, so a redirect of its URL to a private address is followed. With the global switch on, an update that asks for more sites is not held back. Only Safari web extensions bundled with apps in `/Applications` are offered (`engine::extensions`); nothing runs until the user turns an extension on for the current profile in Settings › Extensions, which lists every requested permission and site pattern. Turning it on grants all of them (no per-site prompts). Each profile has its own `WKWebExtensionController`: storage is keyed by the profile's own data-store UUID, also when it shares website data with another profile, the private space gets an in-memory controller with nothing enabled, Lockdown profiles and Lockdown-level views get no controller, and hosts with a Lockdown override are denied to every extension (checked: the content script stops answering), because a link into such a host keeps its view. An extension sees only the tabs of its own profile. Its `safari-web-extension://` origin (Safari's scheme, which Bitwarden's inline menu requires), which pages can see, is derived from the profile's data-store UUID, so it differs per user and profile; sites that probe for Bitwarden's Safari pages find it as they would in Safari. `windows.create` opens a window only for the extension's own pages (Bitwarden's unlock, passkey and edit popouts), at most four per extension, each side between 200 and 1000 points and the height kept on screen; the window's top-level navigations are held to the extension's own pages, because it has no navigation policy or Shield, and it closes when the extension is turned off or its data is removed. Only the extension that opened it sees it. Frames inside it are not restricted and it shows no origin chip, as with the extension's toolbar popup. Native messages and native ports are answered only while Settings › Extensions › "Bitwarden integration" is on, which it is not by default (`Pref::ExtensionsBitwarden`; switching it reloads Bitwarden with or without them, and off it runs like any other app extension), and only for an app extension whose code signature is Bitwarden's (`com.bitwarden.desktop.safari`, signed by team `LTZ2PFU5D6`, or by Apple for the Mac App Store with that team's entitlement), checked when extensions are discovered, and only for the four Bitwarden uses (`copyToClipboard`, `readFromClipboard`, `sleep` with at most 16 pending, `showPopover`); a native port (`connectNative`) is accepted only for Bitwarden's app id, at most four per extension, closed with the extension, and answers only Bitwarden's biometrics questions as its Safari app extension does: Touch ID through LocalAuthentication, then the user key the Bitwarden desktop app keeps in the login keychain (`Bitwarden_biometric`, account `_user_biometric`), read off the main thread after Touch ID succeeded and handed only to that port; one Touch ID prompt at a time, naming the extension; while Bitwarden runs in a profile with that integration on (turned off, pages already open keep this until they reload), pages there (not at Lockdown) are told that passkeys and conditional mediation are available, as in Safari, but only in frames where `navigator.credentials.get` has been replaced again, by Bitwarden's page script or the page itself; WebKit says no without Apple's browser entitlement and refuses conditional requests at once, so in those frames such a refusal of a request with an abort signal stays pending until the page aborts it, as Safari's conditional UI does, and Bitwarden's answer is not cut short; elsewhere WebKit's own answers are returned, the availability one after waiting while the document still parses, at most 40 checks 50 ms apart; clipboard writes need the granted `clipboardWrite` permission and reads also need `clipboardRead` in the manifest, which Settings then lists. Deleting a profile removes its extensions' data through WebKit and then WebKit's folder for it, whose `State.plist` names each extension; "Delete everything" removes the data and restarts the profile's extensions. Tarn has no internal web pages to reach. Extensions can also be installed from a GitHub repository, the signed official catalog (own ed25519 key, domain-separated signature, rollback and 30-day freshness checks, a revoked set that only grows) and `.zip`/`.crx` files: archives are unpacked with strict name, size, depth and type checks into read-only per-install directories; storage is keyed by a random install id; the tree hash is recorded at install and checked before every load, `.appex` bundles included, and a mismatch turns the extension off and drops its site grants; trust labels and the Bitwarden privileges (native messages, clipboard read, passkey script, pop-out windows) follow the install source, never the manifest; unpacked extensions show a popup only after a toolbar click. Host access is per site: the grant-all loop is gone, WebKit's own URL prompt becomes a tab-modal Allow/Deny with Remember (Once lasts an hour), decisions are stored per install and profile, and App and Official sources may be switched to "Allow on every site", which turns off when an update asks for more sites (without effect while the global switch is on). Extension pages, workers and popups get the profile's private-network and HTTPS rule lists. `Tab` refuses `loadURL`, reload, back, forward and zoom without access to the tab's page. Updates are a new install with the same prompt, never automatic. Tarn extensions (`manifest_version` 3 with `browser_specific_settings.tarn.runtime` 1) run on Tarn's own runtime (`browser_core::tarn_ext`, contract `engine::tarn_ext`), the same on every engine: a package using any manifest key, permission (only `storage`, `activeTab`, `declarativeNetRequest`), content-script option or network-rule action outside the subset is refused at install with the key named, and `redirect`, `modifyHeaders` and `allowAllRequests` rules always are, as are a `priority` other than 1, a port in a site pattern and more than 1000 `regexFilter` rules; content scripts and their CSS run only in the install's isolated world `tarn-ext-`, only in http and https frames, only where the engine's synchronous gate (`frame_decision`) allows them, which needs a grant for the frame's host from the same per-site machinery (App and Official may use every site, Unverified always ask, Lockdown hosts denied, Once one hour or until the tab closes, one prompt per site and session); nothing runs in private spaces, burner tabs, Lockdown profiles or Lockdown-level views: no extension page opens in a Lockdown profile, the pages already open close when a profile moves into Lockdown (`Runtime::level_changed`, called by every shell), and its messages and action clicks are refused. Messages travel only between the install's isolated worlds, its own pages and the shell's router (`tarn_ext::router`): the engine defines the transport only in that world or page and reports where a call arrived, so the sender (install, tab, frame, page) never comes from the message; a main frame's message counts only while the install holds a grant for the tab's host (and, where the engine reports the main frame's origin, only when it is the tab's) and a subframe's only while it holds one for the frame's own origin as the engine reported it, a plain `http` document's only when one of the install's site patterns also covers `http`, and no frame inside a page of a Lockdown host runs a script or sends a message; each message is JSON of at most 1 MiB, at most 200 per second per install and tab, malformed ones dropped; a reply counts only from a receiver the message went to; `tabs.query` shows the URL and title only of tabs whose host the install holds a grant for or that `activeTab` gave it; `tabs.sendMessage` reaches only such tabs; `tabs.create` opens web pages only through `nav_policy`, at most 3 in 10 s, never a private-network address (S10); `storage.local` holds JSON per profile and install, at most 5 MiB with keys up to 1 KiB, in memory for a private profile, and is deleted with the install. Static network rules (at most 5 files of 4 MiB, 30,000 rules) compile into one content rule list per install whose block and upgrade rules act only on top-level sites the install holds a grant for (every site only with the trusted switch, minus the hosts the user denied for the install and Lockdown hosts); the grant is the host's whatever the scheme, so they also act on a plain `http` page of a granted host, also for an install whose site patterns name only `https` (WebKit's `if-domain` names no scheme, and the `if-top-url` that could cannot share a list with it); a rule without `resourceTypes` leaves out top-level documents as in Chrome, and one for only main or only sub frames is kept to them (`load-context`); `excludedRequestDomains`, and `excludedInitiatorDomains` together with `initiatorDomains` or `domains`, are refused, because a content rule list can only lift every earlier rule; `allow` rules lift only the same install's rules, never Shield's, and no list is attached in private spaces, Lockdown profiles or Lockdown-level views. Extension pages are served from `tarn-extension:///`, the origin id the first 32 hex digits of SHA-256 of the profile's data-store seed and the install id, only from the install's read-only directory, whose tree hash is checked when the install loads (files are read on request; a change after that check is found at the next load, which turns the install off), with paths that leave it refused, with `script-src 'self'; frame-src 'self'; object-src 'none'`, so its frames are only its own pages or `about:` ones; web pages cannot load the scheme (no `web_accessible_resources`). The background page is started on its first event and closed after 30 s idle; one that does not get ready within 30 s is closed and its waiting callers get an error, and at most 64 messages wait for a page; a reply not given within 30 s ends with an error, at most 256 replies wait per install, and the background page's own calls do not keep it running. The tree hash is checked before every load and a mismatch turns the install off and drops its grants; Tarn extensions get none of the Bitwarden privileges whatever their source. On macOS and Windows the gate is asked in the navigation callback of every frame before the engine is answered, and its answer travels in the world's scripts (`tarn_ext::injections`); a document whose answer did not arrive first runs nothing, and on WebKit a view without a gate (the link peek) holds an empty answer for each of its documents, so no tab can let that document run, until it gets a gate or closes. WebKit (macOS) runs the scripts in a `WKContentWorld` named after the install with a script message handler added only to that world, and takes the frame from WebKit's own message (subframes by WebKit's private `_handle.frameID`; without it a subframe cannot send), each subframe document numbered on its own per install and holding a random value the install's world draws at document start and sends with every message (a message with another value from a frame that has a newer document is dropped); WebKit runs a reply in whatever document the frame shows, so the reply runs only where that value matches, never in the frame's next document, and a fragment navigation or a load that never commits keeps the document and its replies; extension pages are views of their own with the bootstrap in their main world, a handler that answers only the main frame of the install's origin and a `tarn-extension` scheme handler that serves only that origin. Chromium (macOS and Windows) does the same over the in-process DevTools channel only (S22): new-document scripts in an isolated world named after the install, a `Runtime.addBinding` limited to that world's name and taken out of its global before any content script runs, each context's frame and origin taken from DevTools' own `Runtime.executionContextCreated` (never from what a script sends), replies by `Runtime.evaluate` into those contexts. Frames in another process (cross-site iframes) are attached over the same channel (`Target.setAutoAttach` for iframes only, flattened, each waiting before its first document): a frame gets the same binding and scripts in its own session before it is resumed, an install added later gets them in every attached frame, and its contexts are known by session and context id, so its identity comes from the session DevTools reported, never from a script. The Runtime and Page domains are on in tabs of a profile with Tarn extensions, so a page there can tell that a DevTools client is attached (console argument previews); they stay on because without the Runtime domain no binding reaches a new document's context (checked: no `Runtime.bindingCalled` from any new document), and `Page.createIsolatedWorld` with a binding by context id reaches a frame only after its document has started, too late for `document_start` scripts. Checked at run time in a signed debug bundle on macOS (`engine/tests/tarn_extension_chromium.rs`, `app/tests/tarn_extension.rs`) and in WebKit (`engine/tests/tarn_extension.rs`): the isolated world, messages both ways, storage, the network rule only with a grant, no extension file loads from a web page, frame identity in same-site and cross-site frames after reloads and navigations, an install added after a cross-site frame was attached, nothing in a Lockdown view or profile, and an extension page framing only its own origin. The Runtime domain and auto-attach are turned off again in a view when its last install is removed, which detaches its frames' sessions; an install added later attaches them again. An install added (or added back) while a cross-site frame's navigation is in flight does not run in the document that navigation commits: DevTools holds the commands for that frame's session until the commit, after the document's contexts exist, so nothing runs or is heard there (it fails closed) and the frame's next document runs the install. Open on Chromium: not confirmed against Blink whether `Page.addScriptToEvaluateOnNewDocument` with a `worldName` creates that world with universal access; if it does, content scripts there can reach more than in a WebKit content world. `document_end` scripts start after a round trip to the shell, so they can run after the page's `load` event; extension pages register the scheme per request context on Windows only, where it is a standard, secure, display-isolated scheme in every process; the request context is the profile's, so its handler serves only the browser of the page view of that origin and refuses every other one. Store install link (new boundary: a web page leads to an install prompt): only a main-frame navigation the user started (a typed or other shell load that is not a link or pop-up the shell loads for a page, or a link click with a user gesture; `nav_policy::store_link_asks`) to exactly `https://extensions.tarnbrowser.com/install/` (`engine::tarn_ext::store_install`: https, that host, no port, no user info, a valid catalog id, query and fragment ignored) is cancelled before any request; the page passes nothing but the id and gets no channel into the browser. The link itself makes no request: if Tarn already holds a fresh (at most 30 days old) verified copy of the signed catalog, Settings › Extensions shows a confirmation built only from that entry (name, description, version, permissions, optional permissions, sites; `extensions::install::store_step`, `store_sheet`), otherwise a notice points to Settings › Extensions, where the user can load the catalog, and nothing else happens. Requests start only when the user presses Install there: Tarn first checks everything again (`store_confirm`: the same entry in a fresh catalog, not revoked or installed, no install in progress, and `Core::store_link_allowed` for the tab), then downloads, verifies and unpacks the package as for Settings › Extensions › Official; a package whose manifest stays within that entry (`vet`, as always) installs without a second prompt. A page cannot swap what the user confirms: a new store link replaces the sheet under a new token (`install::StoreToken`: a sequence number, the entry's id and SHA-256), the Install button carries the token of the sheet it was drawn for and `StoreSheet::take` refuses any other, and Install clicks within 700 ms of a sheet appearing or being replaced are ignored (`STORE_CONFIRM_DELAY`; on macOS and Windows also while the window layout is not stable, as for the S5 hand-off rule); closing Settings › Extensions drops an unanswered sheet. An unknown, revoked or already installed id or an install in progress gets a notice, and nothing is offered in a private space, a burner tab, a Lockdown profile, from a page at Lockdown or while the store's host is at Lockdown. Every client takes at most one store link per 10 s and ignores the rest without a sheet (`Core::admit_store_link`). Redirects into the address, subframes and script navigations without a gesture load normally. A script that navigates while handling the user's click counts as the user's, as for pop-ups. WebKit on macOS tells a user's click from a script's `a.click()` only through WebKit's private `_isUserInitiated`, and redirects through `_isRedirect`; where they are missing only shell loads ask. Chromium uses CEF's user gesture, Android WebView `hasGesture`, WebKitGTK `is_user_gesture`. iOS uses no private WebKit API and has no public user-gesture or redirect flag: a shell load or any main-frame `linkActivated` navigation asks, so a page's own script-started link click (and a redirect after a link click) can raise the confirmation there, at most once per 10 s; it requests and installs nothing without the user's confirmation. Open: on Linux the user's own click on an install link inside a frame also opens the consent (WebKitGTK does not say which frame a navigation targets). | | S5 | High | Origin spoofing; a sidebar-only UI hides the URL | Origin chip always visible; registrable domain emphasised; punycode for mixed-script names. Prompts and dialogs show the origin and are tab-modal. | Origin chip shows the host as parsed by `url` (IDNA to punycode); a `blob:` page shows the host of the URL it wraps and a page without a host (an opener-filled `about:blank`, `data:`) shows only its scheme (`about:blank`, `data:`), as does its tab title when the page set none, so the chip is empty only when no page is loaded. While a navigation the page started is pending, WebKit's `URL` already names its target over the old content; `WebView::url` then returns the committed URL (`Delegate::shown_url`; `about:blank` for a pop-up before its first commit), so chip, peek header and site settings keep naming the page on screen. Only a server redirect (WebKit's private `_isRedirect`) of the navigation the shell itself started with `load` continues the user's load (`Delegate::user_load`); a navigation the old document starts while that load is pending, and its redirects, are the page's own for S10. Without the selector no hop counts as the user's. For the chip, `user_navigation` still covers the time until the user's load commits or any load fails. The link peek header uses the chip's label (`toolbar::site_of`). Dialogs, permission, sign-in and client certificate requests are tab-modal cards naming the origin (shortened from the left so the registrable domain stays visible) and the embedding page for frames; a permission card's Allow and Remember ignore clicks for 700 ms after the card becomes visible, a banner above it appears or leaves, or the window becomes active (which also covers leaving element fullscreen). A client certificate request comes only from the page's own origin (or, in Chromium tabs, the one its main frame is navigating to), never for a proxy, and lists the certificates that may answer it (WebKit: Keychain identities valid now, `kSecMatchValidOnDate`, and issued by one of the server's named issuers, `kSecMatchIssuers`, when it names any; Chromium: the list Chromium filtered); its certificate buttons are guarded the same way, none is the default, and Cancel, a refused request or a closed card sends no certificate (Chromium remembers that for the host until Tarn restarts). All guarded controls (this one, a certificate choice, S6's "Open", S25's "Visit Anyway", a notice's offer) share one timer (`Browser::layout_stable_since`), restarted when any of them appears or changes in the active tab, a banner appears or leaves, the tab or overlay changes, the window becomes active or the sidebar is resized, and when the sidebar is shown or hidden it runs from the end of the slide (Linux: Visit Anyway's `guard_since`; mobile: Keep in the downloads pop-over, which hangs from the sidebar). Clean Up never names a group after a site, so a group name says nothing about the origin of the tabs in it; the origin chip stays the trust signal. A page on a site no rule knows can pick its own topic group through its address and title, but never outvotes a known site and never lands in Money or Mail and Chat, which take known sites only, and a group named after a category never learns a host from the tabs in it, so a lookalike is not filed next to the real bank or mail tab; only loose tabs move, and the store never moves a tab from one group into another. A page-requested hand-off to another app names the requesting site ("A page" when its origin is opaque or while a main-frame load is in flight, as in S6), is rate-limited like other prompts, is not replaced while shown, ignores clicks for 700 ms after it appears and shows only in its own tab, hidden while the user is on another tab. A Shift-click link peek follows the pop-up rules and their rate limit. | | S6 | High | Dangerous schemes and untrusted URL sources | Allowlist `http`, `https`, `about:blank`, `blob`. `data:` not at top level. `file:` only by explicit user action. `javascript:` rejected in the command bar and on paste. External schemes prompt each time. URLs from other apps, drops and sync pass the same policy. | `nav_policy::decide` with table test; applied to typed input, Open File (`load_file` is the only load that reaches `file:`, decided as `Source::FileOpen` through `nav_policy::file_open`, which also admits only the user's Back, Forward and Reload onto a file that view itself opened, never a restored history; an opened page loads `file:` subresources and frames only from its own folder, or only itself when that folder is a root, a mounted volume's top or holds the home folder, with symlinks resolved and `file:` URLs naming a host refused before any lookup (macOS WebKit's read-access grant and `nav_policy::file_subresource_allowed` for frames, Chromium's request filter (not yet verified at runtime that CEF hands it `file:` subresources; macOS opens files in WebKit), iOS's grant, Android's `shouldInterceptRequest`; Linux gap in `docs/nsh-plan.md` §4), so its images and styles load, and file pages cannot read other files with scripts; the address shows `File:` and the file's name; iOS and Android copy the picked file into a folder of its own under a staging directory cleared at launch), command-line URLs, restored tabs and session snapshots, main-frame navigations, redirects and popups. A page's external-scheme request shows a banner naming the origin of the frame that started it ("A page" when opaque or while a main-frame load is in flight, so a server redirect is never credited to the page or frame that linked to it), only in its own tab, until that tab's next commit or close; while it shows, further requests are dropped, and "Open" ignores clicks for 700 ms after it, or any banner above it, appears, and again when the window becomes active. Links other apps send (the default-browser case, `shared::open_urls` through GPUI's `on_open_urls`) pass `decide(ExternalApp)`, at most 10 in 10 s across the app (the rest are dropped with a toast), and load as a page's link (`WebView::load_link` with no opener), so S10 refuses a local target or any redirect hop into the local network with its usual notice; typing the address opens it. A loopback link (`localhost`, 127.0.0.0/8, `::1`) opens as typed while Settings › Privacy › Open localhost links from other apps is on (the default), since developers open local servers from terminals and editors; the accepted risk is that a link from a remote sender (a mail) can then reach a service on this computer, as a typed address could. Off, it gets the notice. Other local addresses always get it. The notice offers Open Anyway, which loads the address as the user's own navigation. Chromium tabs do the same: their `load_link` sets no shell mark, also for a load held until the view is ready, so `on_before_browse` credits the page (a Chromium integration test is not written yet); such a load is not a user's, so it does not bridge WebKit's cookies first and the site may open signed out in Chromium. Open: public names that resolve to private addresses (`nip.io`-style) are not recognised. | | S19 | High | Sync storage is read or tampered with | Client-side authenticated encryption; remote data validated as untrusted input; secrets and cookies never synced. | Not built. | | S7 | Medium | TLS downgrade or click-through | WebKit's default trust evaluation, never custom acceptance, and no bypass at any level. Chromium tabs cancel certificate errors and turn Chrome's override off, so its certificate page has no way through. | No custom trust handling exists. Plain-HTTP page navigations into an HTTPS-only site are blocked (a URL with an explicit port loads when the view was built HTTPS-only, because `make-https` leaves ports alone; Chromium tabs, which have no per-level view, upgrade such a link without a port and refuse one with a port unless the page being left is HTTPS-only). | -| S8 | Medium | Local data at rest | File permissions and FileVault (documented). Private profile in memory only. Wipe covers data store, history, kept page text, protected-site hosts (at most 200 a profile, the busiest kept, since a page can choose the hosts it is upgraded to), favicons, site zoom levels, muted sites, downloads list and saved `interaction_state`. No URLs in logs. | DB `0600` in `0700` dir; private profile uses in-memory DB. `secure_delete` is on and clearing history, deleting a profile's data, deleting a profile or deleting a space truncates the WAL, so deleted rows are not left in the files. "Delete everything" removes WebKit's public website data types; WebKit-private state such as its HSTS host list is not covered. A Lockdown profile uses a non-persistent WebKit store and empties its own persistent store whenever the profile is opened at that level (`crates/app/tests/lockdown.rs`); a store it shares from another profile ("Share data") stays with that profile, which keeps using it, while the profile that owns a shared store empties it for both when it moves into Lockdown; a request still in flight at the switch can set a cookie after the wipe, which the next Lockdown launch removes. Chromium has one profile, owned by one Tarn profile: deleting that profile's website data, deleting the profile or moving it into Lockdown clears cookies, HTTP cache and sign-ins through CEF, keeps Chromium closed until the next launch, and deletes everything under `Chromium/` once CEF is gone, at quit or before CEF starts at the next launch; a profile at Lockdown at launch or quit loses its Chromium folder and ownership before CEF starts. Chrome's disk cache is kept inside that folder. Per-site Clear Site Data and a site set to Lockdown remove the site's Chromium cookies (host, parent domains and subdomains), the storage of its origins on default ports and of open tabs on that host, and the whole HTTP cache; storage of sibling subdomains and session storage stay. Per-site zoom (`site_zoom`, host and factor per profile) is cleared with history, never written for a Lockdown page, and kept in memory for the private profile; the downloads list can be cleared from the library. Lockdown still records history and tabs for session restore, and a per-site Lockdown override uses the profile's store; the private space keeps nothing. The panic file `last-panic.txt` keeps the panic's location and backtrace and only a literal (`&'static str`) message; a formatted one, which may carry a page address, is left out (`lib.rs::record_panics`, tested). A burner tab (`Model::open_burner`) is a hidden private-store space with its own profile at Strict, so its WebKit store is a non-persistent one of its own, never shared with the private space or another burner, and never Chromium; it records no history, site icons or downloads rows (`Core::keeps_records`), refuses pop-ups and pinning, and leaving it, closing its tab or its window deletes every row of its profile (spaces, tabs, zoom, permissions, counters and the rest of `PROFILE_TABLES`), closes a peek opened from it and drops its data store (`Model::burn`); the emptied profile row stays in memory until the last window closes, so its id is not reused while a late download still names it. A window's Undo (`browser_core::undo::Stack`) keeps in memory only, and only for the window's life, the serial of a reopen-stack entry, a Clean Up record (tab and group ids and positions) or a sidebar move; a close, Clean Up or move in a private space or a burner tab adds nothing (`Stack::push`, tested), and a reopen-stack entry is the same one Reopen Closed Tab already keeps. Shortcut tips (`browser_core::hints`) count per profile in `feature_hints` (a command's name, how often its tip showed and when), a profile table, so export, Delete everything and deleting the profile cover it (`feature_hints_count_per_profile_and_go_with_the_profile_and_its_reset`); a private space or a burner tab shows no tip and counts nothing. Snippets (`browser_core::snippets`, name and text, at most 16 KiB each) live per profile in `snippets`, a profile table, so export, Delete everything and deleting the profile cover them (`snippets_are_checked_per_profile_and_go_with_the_profile_and_its_reset`); a private space or burner tab has a profile of its own and so no snippets. Notes (`browser_core::notes`, a title of at most 200 characters and text of at most 64 KiB, 1000 a profile, without control, bidi or zero-width characters: `store::is_invisible`) live per profile in `notes`, a profile table, so export, Delete everything and deleting the profile cover them (`notes_are_clean_capped_per_profile_and_go_with_the_profile_and_its_reset`); `Store::save_note` refuses a private profile, which private spaces and burner tabs use, so nothing of theirs is written (`notes_are_never_written_for_a_private_profile_and_stop_at_the_cap`). Notes are never synced. | +| S8 | Medium | Local data at rest | File permissions and FileVault (documented). Private profile in memory only. Wipe covers data store, history, kept page text, protected-site hosts (at most 200 a profile, the busiest kept, since a page can choose the hosts it is upgraded to), favicons, site zoom levels, muted sites, downloads list and saved `interaction_state`. No URLs in logs. | DB `0600` in `0700` dir; private profile uses in-memory DB. On Windows the data folder takes Local AppData's user-only access list; a portable Tarn gives its `Data` folder a protected one for the current user, SYSTEM and Administrators at start unless it already has one (`engine::restrict_to_user`), and shows a storage warning whenever that fails, as on FAT and exFAT drives or a folder another account owns. `secure_delete` is on and clearing history, deleting a profile's data, deleting a profile or deleting a space truncates the WAL, so deleted rows are not left in the files. "Delete everything" removes WebKit's public website data types; WebKit-private state such as its HSTS host list is not covered. A Lockdown profile uses a non-persistent WebKit store and empties its own persistent store whenever the profile is opened at that level (`crates/app/tests/lockdown.rs`); a store it shares from another profile ("Share data") stays with that profile, which keeps using it, while the profile that owns a shared store empties it for both when it moves into Lockdown; a request still in flight at the switch can set a cookie after the wipe, which the next Lockdown launch removes. Chromium has one profile, owned by one Tarn profile: deleting that profile's website data, deleting the profile or moving it into Lockdown clears cookies, HTTP cache and sign-ins through CEF, keeps Chromium closed until the next launch, and deletes everything under `Chromium/` once CEF is gone, at quit or before CEF starts at the next launch; a profile at Lockdown at launch or quit loses its Chromium folder and ownership before CEF starts. Chrome's disk cache is kept inside that folder. Per-site Clear Site Data and a site set to Lockdown remove the site's Chromium cookies (host, parent domains and subdomains), the storage of its origins on default ports and of open tabs on that host, and the whole HTTP cache; storage of sibling subdomains and session storage stay. Per-site zoom (`site_zoom`, host and factor per profile) is cleared with history, never written for a Lockdown page, and kept in memory for the private profile; the downloads list can be cleared from the library. Lockdown still records history and tabs for session restore, and a per-site Lockdown override uses the profile's store; the private space keeps nothing. The panic file `last-panic.txt` keeps the panic's location and backtrace and only a literal (`&'static str`) message; a formatted one, which may carry a page address, is left out (`lib.rs::record_panics`, tested). A burner tab (`Model::open_burner`) is a hidden private-store space with its own profile at Strict, so its WebKit store is a non-persistent one of its own, never shared with the private space or another burner, and never Chromium; it records no history, site icons or downloads rows (`Core::keeps_records`), refuses pop-ups and pinning, and leaving it, closing its tab or its window deletes every row of its profile (spaces, tabs, zoom, permissions, counters and the rest of `PROFILE_TABLES`), closes a peek opened from it and drops its data store (`Model::burn`); the emptied profile row stays in memory until the last window closes, so its id is not reused while a late download still names it. A window's Undo (`browser_core::undo::Stack`) keeps in memory only, and only for the window's life, the serial of a reopen-stack entry, a Clean Up record (tab and group ids and positions) or a sidebar move; a close, Clean Up or move in a private space or a burner tab adds nothing (`Stack::push`, tested), and a reopen-stack entry is the same one Reopen Closed Tab already keeps. Shortcut tips (`browser_core::hints`) count per profile in `feature_hints` (a command's name, how often its tip showed and when), a profile table, so export, Delete everything and deleting the profile cover it (`feature_hints_count_per_profile_and_go_with_the_profile_and_its_reset`); a private space or a burner tab shows no tip and counts nothing. Snippets (`browser_core::snippets`, name and text, at most 16 KiB each) live per profile in `snippets`, a profile table, so export, Delete everything and deleting the profile cover them (`snippets_are_checked_per_profile_and_go_with_the_profile_and_its_reset`); a private space or burner tab has a profile of its own and so no snippets. Notes (`browser_core::notes`, a title of at most 200 characters and text of at most 64 KiB, 1000 a profile, without control, bidi or zero-width characters: `store::is_invisible`) live per profile in `notes`, a profile table, so export, Delete everything and deleting the profile cover them (`notes_are_clean_capped_per_profile_and_go_with_the_profile_and_its_reset`); `Store::save_note` refuses a private profile, which private spaces and burner tabs use, so nothing of theirs is written (`notes_are_never_written_for_a_private_profile_and_stop_at_the_cap`). Notes are never synced. | | S9 | Medium | Cross-profile leaks through shell features | Favicons, suggestions, permissions, downloads, extensions and AI context keyed by profile. Favicons are fetched by the tab's own web view, not by the shell. | Schema keys rows by profile; suggestions query one profile. A link peek (⇧-click) uses the opener's profile data store and Shield rules and moves only into a tab of that profile. A space rule (`space_rules`, a host or `*.host`) opens a new tab of a matching URL in the ruled space, so in its profile: only for argv and macOS open-URL requests (after `nav_policy` `ExternalApp`), command-bar new tabs and pop-ups from a link the user activated (`target=_blank`, ⌘-click; WebKit's `LinkActivated`) already allowed by `nav_policy` and the pop-up rules, never for a script's `window.open`, which keeps its opener for sign-in and payment flows, and never for a navigation inside a tab. The routed tab is a fresh shell load without the opener, so the page cannot script it, but a page with a user gesture can open a ruled host in the other profile with that profile's cookies. A link from another app keeps its S10 link-load check in the ruled space. Nothing is routed out of a private space or burner tab, and neither is ever a target. Shortcut tip counters are read and written for the current space's profile only (`hints::Throttle`). Notes are read and edited for the current space's profile only; another profile's id edits or deletes nothing, and a note reaches the assistant only as `notes::as_pill` (`Pill::Note`), which `assistant` admits from the session's own profile. | | S10 | Medium | Public sites attacking localhost or LAN devices | Content rule blocks requests to loopback and private address ranges unless the top-level page is itself local. Web Inspector only in the dev profile or by toggle. | Rules generated in `shield::rules`, including userinfo, IPv4-mapped IPv6, trailing-dot, CGNAT (100.64/10) and IPv6 link-local (fe80::/10) forms; each host pattern ends at the path or a numeric port, so `127.example.com` or `localhost:x@evil.com` as the top page does not lift the block, and a top page with credentials or an IPv6 form embedding IPv4 (`::ffff:`, NAT64) never counts as local. A Shift-clicked link is loaded by the shell as a peek, so it gets the same public-to-private check before `PeekLink` is emitted. The peek loads with `WebView::load_link`, which is not a user navigation: the first URL and every redirect hop get the check, judged from the opener's origin until the peek has a page (`crates/app/tests/redirects.rs` covers the user's own loads across redirects). `*.localhost` top pages count as local and rely on the resolver answering loopback for them. Rules compile asynchronously; a WebKit view holds its first load (or session restore) until its level's built-in list is attached, and if that list fails to compile the view loads nothing and shows the error. Chromium tabs get no rule lists; `engine::request_filter` checks each request with `shield::rules::is_local`, which accepts the same forms, and treats the top page as local only when both the main frame's URL and Chromium's first-party site for the request are local, so a local page just left cannot exempt the next page's first requests; a request filter that has no Shield snapshot yet cancels everything. WebSocket handshakes from Chromium tabs never reach that filter, so a public page in Chromium can still open a WebSocket to a local address (open). At Strict, Chromium tabs drop the cross-origin `Referer` header but the next page's `document.referrer` still names the page left (open). Web Inspector is enabled only with Settings › Developer on or in a developer profile (in Chromium tabs, only then does the page menu keep Chrome's Inspect); the local-server probe connects only to 127.0.0.1 on a fixed list of dev ports with a 300 ms timeout. JSON documents are read from the client world with a size cap and parsed with depth, node and text limits (`devkit::json_view`). Both engines also refuse a script-started main-frame navigation from a public page into a local address (`nav_policy::into_private_network`); a navigation the user started (typed, a click in Chromium, or the shell's back, forward or reload) keeps through its redirects. Back, forward and reload count as the user's only when the shell started them, never by navigation type, so a script's `location.reload()` or `history.go()` that a server redirects into the local network is refused. The page left is judged by its origin: a `blob:` page by its inner origin, a WebKit page without a committed origin (a new popup, `about:blank`, `data:`) by the origin of the frame that started the navigation, and anything opaque or without an http(s) origin as public. A back, forward or reload with nothing to go to does not count, nor does the reload after a page's process ends, since a page can end its own process. In WebKit a clicked link and WebKit's own swipe back from a public page into the local network are refused too, since WebKit reports them like a script's; the user types the address, or presses Open Anyway on the notice, which names the address. A link in an assistant answer to a local or home-network host is refused (`browser_core::assistant::links::classify`, not yet in any client). | A page may also not send the top frame or a new window from a public origin to a private address (WebKit `decide_policy`, `create_web_view` and Chromium `on_before_browse`); typed addresses still load. If the built-in rule list fails to compile, a banner says the protection is off. | S20 | High | Tampered or hostile filter lists | Bundle signed by a separate CI key and verified in the app; size caps per file kind and in total; last good bundle kept. Lists are data only: network rules, plain CSS selectors and domains, never scriptlets or code. On Windows, list element hiding is a `