Nacre/docs/engine/privacy-mode.md
astar76 68346f0edb 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 <noreply@anthropic.com>
2026-11-12 17:13:08 -06:00

4.7 KiB

Privacy mode (S024, R1-16)

Privacy mode hides what makes Nacre stand out, so sites can't recognise the browser without cookies. It is on when Settings → Privacy → Privacy mode is on, and in incognito windows unless "Always on in incognito windows" is off. It can be paused per site from the shield menu (privacy.mode_off). Changes apply from each page's next load.

How it works

Layer Where What
Page script inject.rs PRIVACY_JS (privacy_script) runs at document start in every document Servo parses (frames too), and reaches same-origin frames made by script through contentWindow / contentDocument
Network vendor/servo-net/nacre.rs third-party cookies blocked (S023), Accept-Language as Firefox's list (set_language_list)
Frame cookies inject.rs FRAME_COOKIE_JS document.cookie empty and not stored in a frame whose top page is another site (on whenever third-party cookies are blocked)

Noise is seeded by a random value per run (Shared::seed) plus the top-level site (last two host labels; a cross-origin frame reads it from its referrer), so values differ on every site and after every restart but are stable within a site. Replaced functions print as native code (Function.prototype.toString).

Surfaces (Servo 0.7, tests/smoke/pages/fingerprint.html)

Surface Off (engine) On Choice
Canvas (toDataURL, toBlob, getImageData) real low-bit noise on ~1 in 40 colour values randomise per site/run
WebGL readPixels real same noise randomise
WebGL vendor / renderer "Mozilla/Servo" "Mozilla"; WEBGL_debug_renderer_info exists and answers "Mozilla" normalise (Firefox's values)
Audio (getChannelData, getFloatFrequencyData) real ~1e-7 noise randomise
Fonts via canvas measureText real (7 of 32 probed fonts found here) every probed font "installed" (width ± 0.001 px) normalise
Screen size, avail size, colour depth, position real (after the screen_geometry fix: was 0 x 0) smallest of 1366x768, 1536x864, 1920x1080, 2560x1440, 3840x2160 holding the window; 24 bit; 0,0 normalise
hardwareConcurrency real 8 normalise
deviceMemory absent absent Firefox has none either
platform, oscpu, appVersion "Linux", none, "4.0" from the user agent: "Linux x86_64", "Linux x86_64", "5.0 (X11)" (Windows: "Win32", "5.0 (Windows)") normalise (consistent with the UA)
maxTouchPoints, createEvent('TouchEvent') absent, works 0, NotSupportedError normalise (desktop Firefox); the TouchEvent globals stay, removing them broke Wikipedia's search and media documents
navigator.languages, Accept-Language ["en-US"], "en-US" ["en-US", "en"], "en-US,en;q=0.5" normalise (Firefox's form), the same everywhere
Time zone, locale real real kept: changing them breaks clocks and calendars; both come from the system and agree
User agent Firefox form of Servo's (mainstream_ua) same kept
Plugins, pdfViewerEnabled 0, false same engine limit (Firefox lists 5 PDF plugins)
IndexedDB, WebRTC, battery, userAgentData absent absent engine limits
Fonts measured by DOM layout, web workers real real not covered

Compatibility layers added on the way (always on)

  • FONTS_CHECK_JS: Servo's document.fonts has no check(); Cover Your Tracks' script stopped there.
  • COMPRESSOR_JS: Servo has no DynamicsCompressorNode; a pass-through stand-in lets audio fingerprint scripts run (EFF's server answers 500 to the error string Fingerprint2 reports otherwise).
  • Hub::screen_geometry: Servo reported a 0 x 0 screen because Nacre gave it none.

Cover Your Tracks (2026-11-12, direct connection, tests/smoke/coveryourtracks.txt)

Both runs: tracking ads and invisible trackers blocked. Headline: off "nearly-unique" (17.55 bits, one in 191,498), on "unique" (18.55 bits) — the headline is set by the rarest values, which privacy mode can't change: the user agent (Servo's Firefox 153), time zone, the supercookie test (no IndexedDB in Servo). Identifying bits per metric, off → on:

Metric Off On
Canvas hash 17.55 0.90 (randomized by first party domain)
AudioContext 17.55 1.39 (randomized by first party domain)
Touch support 9.69 0.99
Platform 9.71 2.42
WebGL vendor & renderer 7.56 ("None") 3.63 ("Mozilla~Mozilla")
HTTP Accept headers 5.93 4.06
Screen size and colour depth 5.77 4.98
Hardware concurrency 2.10 2.00
Unchanged UA 5.68, time zone 5.02 + 4.69, supercookies 8.3, plugins 2.93, fonts 3.77, WebGL hash 3.59 ("randomized" even off), DNT 2.02, language 0.91 same

Sum of the per-metric bits: about 124 off, 58 on.