Commit Graph
15 Commits
Author SHA1 Message Date
Jake WriterandClaude Opus 5.5 9f94b0ea46 Stop Xvfb when the process that launched it dies (#868)
headless="virtual" started Xvfb in its own session and stopped it only on
the browser's close path. A launcher ended by a signal (timeout, a
supervisor, a cancelled CI job) never reaches that path, so its Xvfb ran
forever, together with the session bus and desktop helpers Firefox
autolaunched on that display.

Both packages now exec Xvfb through `setpriv --pdeathsig TERM`, so the
kernel signals it when its launcher dies, even by SIGKILL. SIGTERM lets
Xvfb remove its own lock and socket, and the autolaunched bus exits when
it loses its X connection. setpriv comes from util-linux.

The leak suite missed this because every crash test keeps the launcher
alive to tear down, and leak_check follows only our descendants, which an
orphan no longer is. test_launcher_sigkill_leaves_nothing_on_its_display
kills the launcher and looks machine-wide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:31:03 -06:00
Jake Writer 6f74fa06df Merge pull request #866 from RinZ27/fix/ip-validation-parsing
Validate IP addresses with standard library parsers instead of regex
2026-10-16 19:12:09 +00:00
Jake WriterandClaude Opus 5.5 813d9bb199 Behave as on an IPv4-only network when the host's IPv6 disagrees with geoip (#857)
* Behave as on an IPv4-only network when the host's IPv6 disagrees with geoip (#849)

With geoip and an IPv4 address, both launchers set network.dns.disableIPv6.
That stops AAAA lookups only, so IPv6-only sites failed with
NS_ERROR_UNKNOWN_HOST (#849), while a URL with an IPv6 literal still connected
and WebRTC still gathered IPv6 candidates. A page could read the host's IPv6
address, and no real network resolves names to IPv4 only while IPv6 literals
connect.

Without a proxy, sites see this host's own addresses, and the identity comes
from its IPv4 address. The launcher now looks up the host's public IPv6
address too. When it geolocates to the identity's timezone and region, IPv6
stays on, as on any dual-stack network. Otherwise, or when the host has no
IPv6 route, it sets the new network:ipv4Only config key, with a LeakWarning
when an IPv6 address was found elsewhere. Behind a proxy nothing changes: the
browser reaches sites only through it.

network:ipv4Only makes the browser behave as a host with no IPv6 route:
lookups return IPv4 addresses only, TCP connections to a routable IPv6
address fail with PR_NETWORK_UNREACHABLE_ERROR as the kernel's would, HTTP/3
refuses IPv6 peers, and ICE gathers no routable IPv6 address. Loopback,
link-local and IPv4-mapped addresses keep working, as they do on such a host.
NetAddr::IsUnreachableOnIPv4OnlyNetwork is the one definition all of these
use.

ipv4-only-network.py checks it in a network namespace with a dual-stack
interface: with the key off every IPv6 path works, with it on IPv6 literals
and AAAA-only names fail at once, dual-stack names use IPv4, and WebRTC
offers no IPv6 candidate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Allow user namespaces for the IPv4-only network guard in CI

Ubuntu 24.04's AppArmor denies unprivileged user namespaces to programs
without a profile, so the guard's `unshare -rnm` failed on the runner.
The spoofing leg now lifts that restriction on the throwaway runner, and
the guard says which setting to change when it is denied locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 20:41:50 +00:00
RinZ27 1830dcd091 Validate IP addresses with standard library parsers instead of regex
In both Python and TypeScript launchers, IP validation used loose regular
expressions that allowed octets above 255 for IPv4 (e.g. 999.999.999.999)
and malformed colon sequences for IPv6 (e.g. :, :::, 1::2::3).

Downstream, these invalid addresses reached WebRTC init script generation
and MaxMind DB lookups, causing broken script calls or unhandled errors
instead of rejecting them early with InvalidIP.

Replaced the regex checks with ipaddress in Python and node:net in
TypeScript, and added test cases covering the boundary strings.
2026-10-15 11:35:55 +07:00
Jake WriterandClaude Opus 5.5 4559d018dc Date fpgen's model within signed 32-bit time, so read-only Lambda launches work (#856)
The pinned model files were dated 2100-01-01 so fpgen's five-week refresh
never replaces them. AWS Lambda keeps file times as signed 32-bit seconds and
reads that date back as 1963, so every launch tried to re-date the files,
Lambda's read-only filesystem raised EROFS, and the launch failed. Had the
error been ignored, fpgen would have seen a 1963 file as stale and fetched
its own model over the pin.

The files are now dated 2038-01-01, which a 32-bit filesystem stores as is.
A file that cannot be re-dated for any reason, not only a permission error,
is also left alone while fpgen still considers it current, so a read-only
image built with the earlier date keeps working. A stale file that cannot be
re-dated still fails the launch.

Fixes #854.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 03:27:42 +00:00
Jake WriterandClaude Opus 5.5 0bb4f14b74 Keep the caller's launch inputs unchanged, and claim the avail screen and touch points baseline protection reports
launch_options/launchOptions filled the caller's config, prefs, args and
addons in place. A config reused for a second launch then carried the first
identity's webGl:vendor in, which read as a GPU the caller named: the second
launch covered its canvas while claiming the host's GPU. The TypeScript
end-to-end test caught it through its Python probe, which calls
launch_options before Camoufox with the same kwargs. Both launchers now work
on copies.

Firefox's baseline fingerprinting protection reports the available screen as
the screen less a fixed taskbar for the claimed OS (48px Windows, 76px macOS,
none on Linux) and collapses more than one touch point to 5, and the browser
applies that to the spoofed values. The launchers still claimed fpgen's
recorded avail rect, adjusted by fix_screen_no_taskbar, so a Linux identity's
config said availHeight 1053 while the page read 1080. follow_baseline_protection
/ followBaselineProtection replaces it and claims what the browser reports.

The end-to-end test now compares a covered canvas by being covered (its
readback is random on every read, so its size was too), launches the
NewContext scenario with canvas_noise, since an uncovered browser binds its
contexts to the host, and checks a headful launch against its own config,
because Xvfb can render on another device than headless.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:39:02 -06:00
Jake WriterandClaude Opus 5.5 0c98d2b734 Look up each spoof by the document's own context, and make the OS, popups and startup prefs per-context or loud
- One helper, RoverfoxStorageManager::UserContextId(), reads the user
  context from a principal, node or window. Every per-context lookup used
  the browsing context instead, which a document from
  createHTMLDocument() or DOMParser does not have, so a canvas there read
  context 0, which held whichever context set its values last: a page
  could see two GPUs (#839) or another context's font list. The setters
  no longer copy their values into context 0.
- UNMASKED_RENDERER_WEBGL and UNMASKED_VENDOR_WEBGL apply stock's
  fingerprinting-protection checks before the spoofed value, as RENDERER
  does, so the two never disagree.
- system-ui, the CSS2 system fonts and WebRTC's fabricated port use the
  context's own OS (NavigatorManager::GetSpoofedOS), not the launch's, so
  a macOS context of a Windows launch no longer resolves Segoe UI.
- CamoufoxWindow sizes only windows the driver opens; a page's popup keeps
  the size it asked for.
- camoufox.cfg applies CAMOU_PREFS through the default branch and quits
  with the reason on stderr when a pref cannot be applied, instead of
  starting without it.
- Delete commented-out prefs; shorten the setter-seal comments into a
  tribal rule; mark the unread navigator.buildID key removed.
- Refresh five patches that only applied with fuzz; the patched tree is
  byte-identical.
- Guards: webgl-renderer-pair covers data and DOMParser documents, two
  contexts and the unmasked vendor; new context-os-system-font and
  popup-window-size; startup-prefs covers the loader's failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:39:02 -06:00
Jake WriterandClaude Opus 5.5 12b81fdada Read the font bundle only through its group layout, and run a lost test
gen-fonts-json.py and verify-fonts.py read the groups listed in groups.json
through _font_bundle.read_groups(). Neither falls back to the per-OS layout
the group layout replaced any more: a bundle without groups.json is an error.

test_salt_of_equal_objects_is_equal had slipped inside another test's body
and never ran; it is back in TestPinnedIdentityIsStable and passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:39:01 -06:00
Jake WriterandClaude Opus 5.5 6c3850f60a Remove dead and duplicated code across the launchers, scripts and CI
Values both launchers hard-coded (marker fonts, the Windows 11 fonts, the
Apple Silicon and Intel Mac core and panel tables, plausible DPR and core
counts, the macOS MacinTalk/Eloquence voices, the cache prefs) now live in
python/src/camoufox/launcher-constants.json, which the TypeScript package
ships as a data file. gen-fonts-json.py and verify-fonts.py read the same
file, so the drifted PingFang marker copy is gone (fonts.json regenerates
byte-identical) and verify-fonts no longer ast-parses fingerprints.py.

- Drop the duplicate fpgen model pin under browser/scripts/data; the TS
  test checks the fpgen package's MODEL_PIN against the Python copy.
- Move pin-fpgen-model.py and clean-fingerprint-data.py to python/scripts.
- Delete the font licence report (font-metrics/licences.py and its saved
  output, open-fonts.txt): the bundle ships as built, so the report checks
  nothing.
- Delete unreferenced files: cleanfonts.sh, python/examples,
  typescript/renovate.json.
- Delete dead code: classify_installs, remove_mmdb, write_upstream_sh,
  bump_release, unused test constants and fixture helpers, the
  _virtual_display attribute writes, package.py's pre-groups font copy (a
  missing groups.json now fails).
- Share require_bundle, zip_entries, gh_headers and parse_shard instead of
  keeping copies; fold GitHubDownloader into CamoufoxFetcher in both
  launchers.
- TS raises ValueError where Python does, and `camoufox version` prints the
  fpgen package version as Python does.
- Python tests get src/ from pytest's pythonpath instead of sys.path
  inserts; skips that hid untested paths now assert or test the behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:38:55 -06:00
Jake WriterandClaude Opus 5.5 5c1fd578ad Read a build's version from its own bundle, refuse browser= with a binary, and cover the canvas whenever the GPU is not the host's
- A named executable's application.ini is found beside it, or in
  Contents/Resources of a macOS app bundle (pkgman.build_file / buildFile),
  and a named executable without one raises instead of borrowing the paired
  build's version. browser= on macOS no longer raises CamoufoxNotInstalled
  or claims the wrong Firefox major.
- browser= together with executable_path or CAMOUFOX_EXECUTABLE_PATH raises
  ValueError instead of silently dropping browser=.
- One function per launcher (plan_rendering / planRendering) decides whether
  the identity claims the host's GPU or the canvas is covered, for the launch
  and for the host identity its contexts keep. A GPU named by webgl_config or
  a preset, or a host GPU fpgen never recorded, now covers the canvas by
  default, and such a browser binds no context to the host.
- setWebgpu keeps a caller pref set to null, as Python's setdefault does.
- stock-gpu-parity verifies SHA256SUMS.asc against Mozilla's release key and
  uses camoufox.webgl.recorded_devices instead of private helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:38:46 -06:00
Jake Writer d9fa53e96b fix: ensuring documentation matches behavior for pinning 2026-10-08 19:59:50 -06:00
Jake WriterandClaude Opus 5.5 159aebedac Claim the host's GPU on its own OS, cover canvas and WebGPU on another, and follow Firefox 156 for browser-owned GPU values
Canvas, WebGL and WebGPU output come from the real OS, driver and GPU. On the
host's OS the identity now claims the GPU Firefox actually renders with; on
another OS canvas and WebGL readback use privacy.resistFingerprinting's canvas
placeholder (canvas_noise, on by default only for another OS, with a LeakWarning).

WebGPU follows the claimed device: navigator.gpu only where Firefox exposes it
(Windows, Apple Silicon), and the host's adapter only when the identity claims
the host's hardware GPU. Otherwise gfx.blacklist.webgpu marks the device
blocked, so requestAdapter() resolves to null as it does for real users on a
blocked or software GPU. The pref is read at startup, so it goes through
CAMOU_PREFS.

Spoofed avail-screen and touch values now pass through stock baseline
fingerprinting protection for the claimed platform (screen-spoofing,
touchscreen-fingerprint-spoofing).

fpgen's records are mostly Firefox 146, and two WebGL values are decided by
the browser rather than the device: Windows extension lists now include
EXT_depth_clamp (ANGLE's D3D11 backend reports it on every feature level in
156), and WebGL1's ALIASED_LINE_WIDTH_RANGE takes the device's WebGL2 value
(Firefox 156 no longer forces a compatibility profile for WebGL1 on Linux).

A new parity guard, stock-gpu-parity, compares stock Firefox at the build's
version, stock Firefox at the release fpgen recorded, and Camoufox claiming the
host's GPU, and fails when Camoufox differs from stock on a value the two stock
releases disagree on. Decisions are recorded in ci/tribal-rules.yml
(cross-os-canvas-is-the-rfp-placeholder, webgpu-follows-the-claimed-device,
webgl-browser-owned-values-follow-firefox).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 19:08:30 -06:00
Jake Writer a4a9286452 fix: minor leak fixes, patch cleanup, webgpu windows/mac leak fix 2026-10-07 15:32:24 -06:00
Jake Writer 914b575e8f feat: working on cleaning up and fixing patches 2026-10-06 20:47:49 -06:00
Jake Writer 658806eb23 chore: major code cleanup/refactor 2026-10-06 19:10:22 -06:00