From 68346f0edbd0ff222c7b92919766db6dd4645c4c Mon Sep 17 00:00:00 2001 From: astar76 Date: Thu, 12 Nov 2026 17:13:08 -0600 Subject: [PATCH] S024: privacy mode that holds up (R1-16) Firefox-consistent anti-fingerprinting script (canvas/WebGL/audio/font noise per run and site; common screen, CPU, platform, touch and WebGL values; frames covered), paused per site, on in incognito. Privacy mode also switches third-party cookie blocking and a Firefox-style Accept-Language in the vendored servo-net; document.cookie is emptied in cross-site frames. Engine gaps fixed on the way: screen geometry (was 0x0), document.fonts.check, a pass-through DynamicsCompressorNode. Settings sub-page and shield flyout explain it. Tests: unit tests, privacy-mode/incognito/net smokes, Cover Your Tracks run recorded in docs/engine/privacy-mode.md. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 1 + Plans/06 Privacy/S024-privacy-mode.md | 14 +- Plans/INDEX.md | 2 +- docs/DECISIONS.md | 1 + docs/DESIGN.md | 16 +- docs/FEATURES.md | 6 +- docs/PROGRESS.md | 10 + docs/engine/privacy-mode.md | 66 ++++++ src/actions.rs | 4 + src/app.rs | 23 +++ src/hub.rs | 19 +- src/inject.rs | 277 ++++++++++++++++++++++---- src/selftest.rs | 22 ++ src/store/settings.rs | 7 + src/ui/menus.rs | 22 +- src/ui/pages/settings.rs | 41 +++- tests/smoke/coveryourtracks.txt | 28 +++ tests/smoke/net/server.py | 18 +- tests/smoke/pages/fingerprint.html | 136 +++++++++++++ tests/smoke/privacy-incognito.txt | 17 ++ tests/smoke/privacy-mode.txt | 54 +++++ tests/smoke/privacy-net.txt | 31 ++- tools/smoke.sh | 3 +- vendor/servo-net/fetch/methods.rs | 2 + vendor/servo-net/nacre.rs | 50 +++++ 25 files changed, 815 insertions(+), 55 deletions(-) create mode 100644 docs/engine/privacy-mode.md create mode 100644 tests/smoke/coveryourtracks.txt create mode 100644 tests/smoke/pages/fingerprint.html create mode 100644 tests/smoke/privacy-incognito.txt create mode 100644 tests/smoke/privacy-mode.txt diff --git a/CLAUDE.md b/CLAUDE.md index b465e15..defa5de 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -73,6 +73,7 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl | `SMOKE_SIZE=1280x1600 tools/smoke.sh tests/smoke/sliders.txt` | controls hold still (R1-21): Interface size drag (value label while held, applied on release), Contrast live, Style chip pick; `SMOKE_VISIBLE=1 tools/smoke.sh tests/smoke/sliders-visible.txt` the same plus scrolling for the user's window (~772 px). Selftest `press`/`drag`/`release`, `scroll x y dy`; read the PNGs | now (R1-21) | | `python3 tests/smoke/net/server.py &` + `tools/smoke.sh tests/smoke/net-{privacy,adblock,downloads}.txt` | network pass, offline: secure DNS through a local DoH stub (`*.nacre.test` → 127.0.0.1), HTTPS-only + certificate warning, tracking params, ad blocker with a local list, downloads + download manager stubs; the server's `/log` has requests, DNS names, Range headers, manager calls. `cache-restart.txt` with `SMOKE_HOME=/home`: disk cache. `net-real.txt` needs internet. `@HOME@` in scripts = the throwaway home | now (S007) | | `tools/smoke.sh tests/smoke/mse.txt` | MSE: MediaSource + one SourceBuffer plays chunk-appended fMP4 and WebM (offline); passes only on a build with the MSE patches (branch `s022-mse-proto`, see docs/engine/mse-spike.md) | S022 prototype | +| `tools/smoke.sh tests/smoke/privacy-mode.txt` (+ `SMOKE_ARGS=--incognito … privacy-incognito.txt`) | privacy mode: `pages/fingerprint.html` read off/on, `fp-off.json`/`fp-on.json` + shots (offline); `privacy-net.txt` (needs `tests/smoke/net/server.py`) frame cookies, per-site pause, Accept-Language; `SMOKE_TIMEOUT=700 … coveryourtracks.txt` EFF's test off/on (internet, direct). Selftest `save ` writes a JS string result to `.json`; `SMOKE_ARGS` passes browser arguments | now (S024) | | `python tools/icons.py` | rebuilds the icon font subset and `src/ui/icons.rs` from `tools/icons.txt` (needs fontTools and Arch's ttf-material-symbols-variable) | now (S015) | | appimagetool, wine + Inno Setup, VM "Windows 10" | packaging and Windows checks | see the user's global CLAUDE.md "Building" | diff --git a/Plans/06 Privacy/S024-privacy-mode.md b/Plans/06 Privacy/S024-privacy-mode.md index 3cc0c5a..513a647 100644 --- a/Plans/06 Privacy/S024-privacy-mode.md +++ b/Plans/06 Privacy/S024-privacy-mode.md @@ -11,13 +11,13 @@ R1-16: privacy mode must be genuinely useful: anti-fingerprinting (canvas, WebGL - `src/inject.rs` (how scripts are injected per page and frame), the Protection flyout in `src/ui/menus.rs` ## Steps -- [ ] List the fingerprint surfaces Servo 0.7 exposes (a local test page printing each value) and pick per surface: normalise (common value) or randomise per session/site -- [ ] Inject the spoofing script at document start in every frame when privacy mode is on (per site and global), consistent across APIs (UA ↔ platform ↔ timezone ↔ language) -- [ ] Switch on S023's third-party cookie blocking and privacy headers with privacy mode; incognito windows start with privacy mode on -- [ ] Protection flyout and Settings show what privacy mode does and what's limited by the engine -- [ ] Verify: local fingerprint page before/after (smoke shots + JSON); then one run on coveryourtracks.eff.org (needs internet, no Tor/proxy) and record the result -- [ ] Unit tests for pure logic (value choice, consistency); regression: common sites (heavy-web.txt) still work with privacy mode on -- [ ] PROGRESS entry, INDEX line, commit `S024: …` and push +- [x] List the fingerprint surfaces Servo 0.7 exposes (a local test page printing each value) and pick per surface: normalise (common value) or randomise per session/site +- [x] Inject the spoofing script at document start in every frame when privacy mode is on (per site and global), consistent across APIs (UA ↔ platform ↔ timezone ↔ language) +- [x] Switch on S023's third-party cookie blocking and privacy headers with privacy mode; incognito windows start with privacy mode on +- [x] Protection flyout and Settings show what privacy mode does and what's limited by the engine +- [x] Verify: local fingerprint page before/after (smoke shots + JSON); then one run on coveryourtracks.eff.org (needs internet, no Tor/proxy) and record the result +- [x] Unit tests for pure logic (value choice, consistency); regression: common sites (heavy-web.txt) still work with privacy mode on +- [x] PROGRESS entry, INDEX line, commit `S024: …` and push ## End criteria - Local fingerprint page shows the normalised values with privacy mode on and real ones off; Cover Your Tracks result recorded; heavy-web smoke still passes with privacy mode on. diff --git a/Plans/INDEX.md b/Plans/INDEX.md index e5c281b..bab1f0d 100644 --- a/Plans/INDEX.md +++ b/Plans/INDEX.md @@ -43,5 +43,5 @@ Tracker: https://claude.ai/artifact/9AD7fPfwJ4ASFzVTJGKU4h ## 06 Privacy - [x] [S023 — Request headers and third-party cookies in servo-net](06%20Privacy/S023-net-headers-cookies.md) · Opus medium -- [ ] [S024 — Privacy mode that holds up](06%20Privacy/S024-privacy-mode.md) · Opus high +- [x] [S024 — Privacy mode that holds up](06%20Privacy/S024-privacy-mode.md) · Opus high - [ ] [S025 — Cookies encrypted at rest](06%20Privacy/S025-cookie-encryption.md) · Opus medium diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 10e7cd5..c6e8e6e 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -21,3 +21,4 @@ - D-016 — 2026-11-12 — Patched gst_mse loading (S026). Nacre ships its own `libgstmse-1.0.so.0` and `mse` plugin built from `vendor/gst-mse` (`tools/gst-mse.sh`). Release layout: library in `/lib/`, plugin in `/lib/gstreamer-1.0/`; a dev build uses `target/gst-mse/{lib,gstreamer-1.0}`. The binary's RUNPATH (`$ORIGIN/lib:$ORIGIN/../gst-mse/lib`, from `build.rs`) finds the library ahead of the system copy (same soname), and `main.rs` prepends the plugin dir to `GST_PLUGIN_PATH` before GStreamer starts (paths in GST_PLUGIN_PATH beat the system plugin of the same name). Windows: the DLLs sit next to `nacre.exe` / in `lib\gstreamer-1.0` (unverified). — RUNPATH needs no wrapper script or re-exec; LD_LIBRARY_PATH would have to be set before the process starts. — S030 packaging (AppImage, tarball, Windows), S028 merge - D-017 — 2026-11-12 — Request headers and third-party cookie blocking are Nacre patches in the vendored servo-net (S023): new module `nacre.rs` holds embedder-set state (extra headers, block switch, top-level site per webview); `http_loader.rs` and `websocket_loader.rs` read it. A request is third-party when its host's registrable domain differs from its webview's top-level site; blocking is on when the setting or privacy mode is on (`App::refresh_hub_config`). — Servo 0.7 has neither; the user wants engine fixes. `document.cookie` in cross-site frames stays uncovered (script isn't vendored). — S024 (privacy mode only needs `privacy_mode_on`), any Servo upgrade (re-apply from DESIGN.md "Vendored servo-net patches", re-run `privacy-net.txt`) - D-017 — 2026-11-12 — MSE DOM design (S027). (1) `dom_media_source_enabled` is not a servo-config pref: adding a field to `Preferences` means vendoring servo-config, which rebuilds nearly every Servo crate. Instead the three interfaces carry `[Func="MediaSource::enabled"]`, which reads `NACRE_DOM_MEDIA_SOURCE_ENABLED` once (`0`/`false` = off, default on; `servo_media_player::mse::enabled`). A settings switch, if wanted, sets that variable before Servo starts. (2) The DOM owns the spec state (readyState, updating, both lists, events, always queued as media element tasks); gst_mse owns parsing, buffering and removal. Only `sourceopen` after attaching, update-end/error, duration and active-list changes come from the backend. (3) The backend's event sink names its MediaSource by id through a thread-local map of weak references (no `Trusted`, so a dropped MediaSource is collected). (4) MediaSource object URLs live in a per-global map (`GlobalScope::media_source_urls`), revoked one task later (pages revoke right after setting `src`), cleared on unload. (5) gst_mse defects found here are fixed in vendor/gst-mse like D-016 (patches 5–9 in docs/engine/gst-mse-patches.md). — Keeps rebuilds to servo-script and the media crates; matches Servo's own direction (#22416). — S028 (player integration, merge), S029, any Servo upgrade +- D-018 — 2026-11-12 — Privacy mode looks like desktop Firefox (S024): values that can't be hidden are made consistent with the Firefox user agent (platform, oscpu, appVersion, WebGL "Mozilla", no touch points, Firefox's language list in both `navigator.languages` and Accept-Language); canvas/WebGL/audio/fonts get noise seeded per run and top-level site; time zone and locale stay real; the TouchEvent globals stay (removing them broke Wikipedia). Engine gaps that stop fingerprint or site scripts get a small always-on JS layer (`FONTS_CHECK_JS`, `COMPRESSOR_JS`). — Inconsistent spoofing is itself a fingerprint; Firefox is the UA Nacre sends. — S025 and later privacy or UA work: keep the navigator values in step with any user agent change (`inject::firefox_navigator`). diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 6c70dce..709471f 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -143,6 +143,10 @@ picture-in-picture, extensions, password capture, printing. video" (and PiP finds no video). Plain `