Building an Anti-Fingerprinting Chromium Extension in Fuzio: Part 2 — 3D Graphics, Shaders, and Display

In Part 1, we built a Manifest V3 Chromium extension in Fuzio to protect against 2D canvas and text layout fingerprinting. However, a script can still identify the machine without touching a 2D canvas by querying the 3D graphics context or the monitor configuration — reading the physical GPU model, driver extension list, 3D shader output, HDR bit depth, and multi-monitor layout.
In Part 2 of this series, we extend our extension to protect 3D GPU pipelines, shaders, and display properties across five surfaces:
WebGLRenderingContextandWebGL2RenderingContextfor 3D parameters, supported extensions, and rendered pixel buffers.WEBGL_debug_shadersfor raw ANGLE-translated driver shader code.GPUAdapterInfo(navigator.gpu) for WebGPU hardware vendor and architecture strings.Screen(window.screen) andwindow.devicePixelRatiofor color depth, display scaling, and multi-monitor taskbar offsets.window.matchMedia()for high-entropy HDR, wide-gamut, and accessibility CSS media queries.
Prerequisites
To follow this tutorial, you need:
- The completed project from Part 1.
- JDK 17 or later and a valid Fuzio license key (or a free 30-day trial key).
Revisiting Part 1
In Part 1, we set up the extension infrastructure in
content.js (injected into the MAIN world at document_start) and
packaged it at runtime with CrxPacker. In this part, we reuse three helpers
from content.js:
DOMAIN_SESSION_SEEDandcomputeNoiseBit(index, seed)to generate deterministic per-domain pixel noise.maskFunction(win, patchedFn, origFn)to preserve nativetoString()output on overridden prototype methods and getters.applyAllTechniques(targetWindow)andpatchedRealmsto apply our patches to both the top window and dynamically created iframes.
How 3D GPU and Display Fingerprinting Works
When a web page creates a "webgl", "webgl2", or WebGPU context,
Chromium routes commands through ANGLE (Almost Native Graphics Layer Engine) to
the host graphics driver — Vulkan or OpenGL on Linux, Direct3D on
Windows, or Metal on macOS.
Tracking scripts combine four signals from the GPU and display subsystem:
- Querying
UNMASKED_VENDOR_WEBGL(0x9245) andUNMASKED_RENDERER_WEBGL(0x9246) viaWEBGL_debug_renderer_info, along with texture limits andnavigator.gpu.requestAdapter(), reveals the exact graphics card model and driver backend. - Calling
getSupportedExtensions()andWEBGL_debug_shadersexposes driver-specific capabilities and the translated Metal, HLSL, or GLSL shader source code. - Drawing a 3D mesh with vertex and fragment shaders and reading
the framebuffer with
gl.readPixels()captures GPU-specific floating-point interpolation and anti-aliasing differences. - Inspecting
window.screen,window.devicePixelRatio, andwindow.matchMedia()reveals 10-bit HDR panels, secondary monitor positions, and OS display preferences.
Normalization vs. Farbling
In Part 1, every 2D surface returned continuous pixel arrays or sub-pixel floats, so we added deterministic per-domain noise (farbling) to every read. In the 3D GPU and display subsystem, adding random noise to every property would immediately expose the extension.
If you append random characters to UNMASKED_RENDERER_WEBGL or add noise to
MAX_TEXTURE_SIZE so it returns 16385 instead of a power of two
(16384), anti-bot scripts on BrowserLeaks,
BrowserScan, or ToDetect will flag
the browser for reporting impossible hardware.
Instead, we split our Part 2 defenses into two strategies depending on the API:
- For discrete hardware strings, integer limits, extensions, and display flags, we normalize (clamp) the return values to a common hardware cohort so every profile reports the same valid configuration.
- For continuous 3D pixel buffers (
gl.readPixels()), we apply deterministic farbling usingDOMAIN_SESSION_SEEDfrom Part 1 so each profile and website produces a different 3D rendering hash.
Step 1: Normalize WebGL Parameters and Farble 3D Pixels
Both WebGL 1.0 (WebGLRenderingContext.prototype) and WebGL 2.0
(WebGL2RenderingContext.prototype) define their own prototype methods. In
patchWebGL, we normalize getParameter, filter getSupportedExtensions and
getExtension against BASELINE_WEBGL_EXTENSIONS (blocking
WEBGL_debug_shaders so scripts cannot call
getTranslatedShaderSource()), and farble the caller-supplied pixel buffer
(args[6]) in gl.readPixels():
const WEBGL_UNMASKED_VENDOR = 0x9245;
const WEBGL_UNMASKED_RENDERER = 0x9246;
const WEBGL_MAX_TEXTURE_SIZE = 0x0d33;
const WEBGL_MAX_RENDERBUFFER_SIZE = 0x84e8;
const WEBGL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851c;
const NORMALIZED_RENDERER =
"ANGLE (Apple, ANGLE Metal Renderer: Apple M1, Unspecified Version)";
const BASELINE_WEBGL_EXTENSIONS = new Set([
"ANGLE_instanced_arrays", "EXT_blend_minmax", "EXT_color_buffer_half_float",
"EXT_depth_clamp", "EXT_float_blend", "EXT_frag_depth",
"EXT_shader_texture_lod", "EXT_sRGB", "EXT_texture_compression_bptc",
"EXT_texture_compression_rgtc", "EXT_texture_filter_anisotropic",
"OES_element_index_uint", "OES_fbo_render_mip_map",
"OES_standard_derivatives", "OES_texture_float", "OES_texture_float_linear",
"OES_texture_half_float", "OES_texture_half_float_linear",
"OES_vertex_array_object", "WEBGL_color_buffer_float",
"WEBGL_compressed_texture_s3tc", "WEBGL_compressed_texture_s3tc_srgb",
"WEBGL_debug_renderer_info", "WEBGL_depth_texture", "WEBGL_draw_buffers",
"WEBGL_lose_context", "WEBGL_multi_draw"
]);
function patchWebGL(win, seed) {
const protos = [
win.WebGLRenderingContext?.prototype,
win.WebGL2RenderingContext?.prototype
];
for (const glProto of protos) {
if (!glProto) continue;
const origGetParam = glProto.getParameter;
const origGetExts = glProto.getSupportedExtensions;
const origGetExt = glProto.getExtension;
const origReadPixels = glProto.readPixels;
const getParameter = function (pname) {
if (pname === WEBGL_UNMASKED_VENDOR) return "Google Inc. (Apple)";
if (pname === WEBGL_UNMASKED_RENDERER) return NORMALIZED_RENDERER;
if (
pname === WEBGL_MAX_TEXTURE_SIZE ||
pname === WEBGL_MAX_RENDERBUFFER_SIZE ||
pname === WEBGL_MAX_CUBE_MAP_TEXTURE_SIZE
) {
return 16384;
}
return origGetParam.call(this, pname);
};
const getSupportedExtensions = function () {
const list = origGetExts.call(this);
return Array.isArray(list)
? list.filter((ext) => BASELINE_WEBGL_EXTENSIONS.has(ext))
: list;
};
const getExtension = function (name) {
return BASELINE_WEBGL_EXTENSIONS.has(name)
? origGetExt.call(this, name)
: null;
};
const readPixels = function (...args) {
origReadPixels.apply(this, args);
const pixels = args[6];
if (pixels && typeof pixels.length === "number") {
for (let i = 0; i < pixels.length; i += 16) {
pixels[i] = pixels[i] ^ computeNoiseBit(i, seed);
}
}
};
maskFunction(win, getParameter, origGetParam);
maskFunction(win, getSupportedExtensions, origGetExts);
maskFunction(win, getExtension, origGetExt);
maskFunction(win, readPixels, origReadPixels);
Object.assign(glProto, {
getParameter,
getSupportedExtensions,
getExtension,
readPixels
});
}
}
Step 2: Normalize WebGPU Adapter Information
Even when WebGL strings are normalized, modern Chromium exposes the WebGPU
API via navigator.gpu.requestAdapter(). The resolved GPUAdapter exposes
an info property backed by
GPUAdapterInfo.prototype, whose getters return
the physical GPU vendor, micro-architecture (such as
metal-3ampere, or rdna-2
To keep WebGPU consistent with our WebGL cohort, we introduce a small
helper (overrideGetterValue) that wraps a property getter on
a prototype and masks it with maskFunction. In patchWebGPU, we
normalize all four getters on GPUAdapterInfo.prototype:
function overrideGetterValue(win, proto, propName, constantValue) {
const desc = Object.getOwnPropertyDescriptor(proto, propName);
if (!desc || !desc.get) return;
const patchedGetter = function () {
return constantValue;
};
maskFunction(win, patchedGetter, desc.get);
Object.defineProperty(proto, propName, {
get: patchedGetter,
configurable: true,
enumerable: true
});
}
function patchWebGPU(win) {
const adapterInfoProto = win.GPUAdapterInfo?.prototype;
if (!adapterInfoProto) return;
overrideGetterValue(win, adapterInfoProto, "vendor", "apple");
overrideGetterValue(win, adapterInfoProto, "architecture", "common-3");
overrideGetterValue(win, adapterInfoProto, "device", "");
overrideGetterValue(win, adapterInfoProto, "description", "");
}
Step 3: Normalize Screen Geometry and Color Depth
In patchScreenMetrics, we reuse overrideGetterValue to clamp
Screen.prototype and window.devicePixelRatio to standard 8-bit sRGB (24),
zero taskbar and multi-monitor offsets (0), and a 2x pixel ratio —
without altering screen.width or screen.height, which must remain aligned
with the browser viewport:
function patchScreenMetrics(win) {
const screenProto = win.Screen?.prototype;
if (screenProto) {
overrideGetterValue(win, screenProto, "colorDepth", 24);
overrideGetterValue(win, screenProto, "pixelDepth", 24);
overrideGetterValue(win, screenProto, "availTop", 0);
overrideGetterValue(win, screenProto, "availLeft", 0);
}
overrideGetterValue(win, win, "devicePixelRatio", 2);
}
Step 4: Clamp High-Entropy CSS Media Queries
Anti-bot scripts cross-check screen.colorDepth by evaluating CSS media queries
through window.matchMedia(). If screen.colorDepth reports 24 (standard
8-bit display), but
window.matchMedia("(dynamic-range: high)").matcheswindow.matchMedia("(color-gamut: rec2020)").matchestrue, the mismatch reveals that screen.colorDepth was spoofed. Scripts
also probe OS accessibility flags (prefers-reduced-motionprefers-contrastinverted-colors
In patchCssMediaQueries, we wrap window.matchMedia so queries matching any
of those high-entropy features return a MediaQueryList with matches set
to false:
const CLAMPED_MEDIA_FEATURES = [
"dynamic-range: high",
"color-gamut: rec2020",
"prefers-reduced-motion: reduce",
"prefers-contrast: more",
"inverted-colors: inverted"
];
function patchCssMediaQueries(win) {
const origMatchMedia = win.matchMedia;
if (typeof origMatchMedia !== "function") return;
const patchedMatchMedia = function (query) {
const mql = origMatchMedia.call(this, query);
const normalized = String(query).toLowerCase().replace(/\s+/g, " ");
const shouldClamp = CLAMPED_MEDIA_FEATURES.some((feature) =>
normalized.includes(feature)
);
if (shouldClamp && mql) {
Object.defineProperty(mql, "matches", {
get: () => false,
configurable: true,
enumerable: true
});
}
return mql;
};
maskFunction(win, patchedMatchMedia, origMatchMedia);
win.matchMedia = patchedMatchMedia;
}
Finally, add the four new functions to applyAllTechniques(targetWindow)
from Part 1:
function applyAllTechniques(targetWindow) {
if (!targetWindow || patchedRealms.has(targetWindow)) return;
patchedRealms.add(targetWindow);
patchCanvas2D(targetWindow, DOMAIN_SESSION_SEED);
patchOffscreenCanvas(targetWindow, DOMAIN_SESSION_SEED);
patchCanvasTextMetrics(targetWindow, DOMAIN_SESSION_SEED);
patchSvgTextMetrics(targetWindow, DOMAIN_SESSION_SEED);
patchDomRectMetrics(targetWindow, DOMAIN_SESSION_SEED);
patchWebGL(targetWindow, DOMAIN_SESSION_SEED);
patchWebGPU(targetWindow);
patchScreenMetrics(targetWindow);
patchCssMediaQueries(targetWindow);
patchSandboxedIframes(targetWindow, applyAllTechniques);
patchFunctionToString(targetWindow);
}
Step 5: Verify on BrowserLeaks WebGL in Fuzio
Run the application from fuzio-examples<YOUR_LICENSE_KEY> with your Fuzio license key:
./gradlew :canvas-fingerprint:run -Dfuzio.license.key=<YOUR_LICENSE_KEY>
The application opens three BrowserView panes side by side (No Extension, Protected Profile 1, and Protected Profile 2) on BrowserLeaks
WebGL. Comparing the default profile against
the two isolated profiles running our extension shows both strategies
working together — discrete GPU and display parameters are clamped to
a single hardware cohort across profiles, while 3D readPixels() hashes
differ per profile and repeat identically on a second call within
the same page visit:
| Surface | No Extension | Profile 1 (1st Call) | Profile 1 (2nd Call) | Profile 2 (1st Call) |
|---|---|---|---|---|
| WebGL Renderer | ...Apple M4 Pro... | ...Apple M1... | ...Apple M1... | ...Apple M1... |
| WebGL Extensions | 39 | 26 | 26 | 26 |
WEBGL_debug_shaders | Exposed | null | null | null |
WebGL readPixels | ed4f4145 | 421d640d | 421d640d | 55a502f8 |
GPUAdapterInfo.arch | metal-3 | common-3 | common-3 | common-3 |
screen.colorDepth | 30 | 24 | 24 | 24 |
screen.availTop | 33 | 0 | 0 | 0 |
dynamic-range: high | true | false | false | false |
You can find the complete runnable project in the Gitee repository.
Conclusion
In Part 2 of this series, we extended our Manifest V3 Chromium extension in
Fuzio to protect 3D graphics, shaders, and display APIs by combining cohort
normalization (WebGL parameters and extensions, WebGPU adapter info,
window.screen, and window.matchMedia) with deterministic per-domain pixel
farbling (gl.readPixels()).
In the next part of the series, we will protect audio processing,
multimedia capabilities, and typography enumeration across AudioContext,
OfflineAudioContext, speechSynthesis, mediaDevices, mediaCapabilities,
and document.fonts.
Add a Chromium-based browser engine to your Java desktop app with Fuzio.
Try for free
