When a download failed, maybe_download_addons removed the addon directory
unconditionally. If another process had finished installing the addon in the
meantime, that deleted its good copy, possibly while its browser was loading
it. The handler now removes the directory only when it has no manifest.json,
in both the Python and TypeScript launchers, each with a regression test.
One window remains: two processes that both find a stale, non-empty partial
directory can still interleave its removal and their renames.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The atomic extraction removed the target before renaming into it. With two
processes downloading at once, the second could delete the first's finished
addon while its browser was loading it. If the first renamed in between, the
second's rename failed on the non-empty directory, and its error handler then
deleted the good copy, so it launched without uBlock Origin.
Rename first. If the target is not empty and already holds a manifest.json,
keep it and drop the temp dir; only an incomplete target is replaced. The
TypeScript port mirrors this and gains the atomic-extraction test, and both
gain a regression test for an addon installed during extraction.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
add_default_addons() took `with Lock():` on a multiprocessing.Lock made
fresh for each call, which guarded nothing: two launches in one process
both found no manifest.json and both downloaded and extracted uBO into
the same directory. The lock is now one threading.Lock for the module.
A launch in another process does not see that lock, and it trusts any
addon directory holding a manifest.json. Extraction now goes into a
sibling temp directory that is renamed into place last, so the manifest
never appears before the rest of the addon.
The TypeScript launcher serializes the same check-then-extract on one
promise chain and extracts the same way.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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>
* 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>
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.
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>
Both launchers hard-coded Firefox 156's GetSpoofedScreenAvailSize offsets
(48 Windows, 76 macOS, 0 Linux) and the collapsed touch-point count. They now
read them from the shared constants file, as the other values both launchers
use already do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
- 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>
- The skiplist audit runs each entry in its own pytest process without
upstream's reruns. test_browsercontext_proxy.py shares one browser, and
HTTPS-First's per-host exception means only its first proxied navigation
fails, so every navigating test there is listed and each is audited from
a fresh browser. Record HTTPS-First staying on in ci/tribal-rules.yml.
- Drop the test_worker locale entry and its overlay test: upstream v1.62.0
asserts the same ru-RU behaviour, so the entry passed the audit.
- browser/bundle/fontconfig ships in every package, so it is now a browser
input (BROWSER_DIRS and the resolve grep), with a test that every
--includes path is one.
- Revert the binary-config-keys allowance: a driver-only PR tests the release
paired by source digest, which covers properties.json.
- Playwright guards use helpers.resolve_binary and a new helpers.launch_kwargs
instead of per-file copies.
- Docs: absolute links in the PyPI/npm READMEs, a Python development section,
repository-root markers in the patch guide, Playwright porting merged into
it, fpgen-js, the moved fpgen pin and font-constant files, and the
canvas-noise and browser/executable_path launcher changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
- 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>
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>