Clearing cookies, rotating IP addresses, and creating fresh browser profiles do not stop websites from recognizing the underlying machine. Tracking and anti-bot scripts render invisible 2D graphics, measure sub-pixel glyph geometry, and hash the resulting pixel and floating-point arrays to compute a hardware identifier that persists across sessions.

Because Fuzio embeds Chromium, you can counter these scripts by installing a Manifest V3 extension into a Fuzio Profile and overriding the page’s JavaScript APIs before any tracking script runs.

In this article series, we will build an anti-fingerprinting Chromium extension in Fuzio to protect embedded browsers against tracking scripts.

In Part 1, we focus on 2D graphics and page layout. We will package an extension at runtime and add tiny, consistent adjustments to how the browser draws images, measures text, and calculates element sizes so each profile and website sees a different signature. Specifically, we will cover:

  • HTMLCanvasElement and CanvasRenderingContext2D for standard 2D canvas drawing.
  • OffscreenCanvas for off-screen 2D canvas rendering.
  • TextMetrics for sub-pixel text width and glyph bounding-box measurements.
  • SVG text elements for vector text lengths and bounding boxes.
  • DOMRect for fractional HTML element and text-range layout rectangles.

Prerequisites 

To follow this tutorial, you need:

  • JDK 17 or later.
  • A valid Fuzio license key. You can request a free 30-day trial key on the Fuzio website.
  • A Gradle project configured with Fuzio and Swing. Follow the Quick Start guide if you are setting up a new project.

How 2D Graphics Fingerprinting Works 

When a web page draws text, gradients, or shapes, Chromium passes those commands to its 2D graphics engine (Skia) and the operating system’s font engine (FreeType on Linux, DirectWrite on Windows, or CoreText on macOS).

Even when two computers run the same Chromium version and draw the exact same scene, their hardware and operating systems produce tiny numerical differences. These differences are completely invisible to the human eye on screen, but they change the raw pixel bytes and floating-point numbers returned to JavaScript.

Specifically, three hardware-dependent factors change the rendered output:

  • Different GPUs and graphics drivers round edge smoothing and color gradients differently in the lowest bit of each RGBA color channel.
  • Operating systems apply different font hinting and kerning rules when placing characters at fractional pixel coordinates.
  • Chromium’s Blink layout engine calculates element and text-range bounding boxes with sub-pixel precision that varies by system font metrics and display scaling.

Fingerprinting scripts exploit these differences by drawing a hidden scene, reading back the raw pixel array or bounding-box coordinates, and hashing the values. Because those numbers stay consistent across browser sessions on the same machine, that hash acts as a stable hardware identifier.

The Uniqueness Paradox and Deterministic Farbling 

For simple hardware properties like CPU core count (navigator.hardwareConcurrency), you can blend into the crowd by returning a standard value such as 8. For 2D graphics and layout APIs, the browser must render and measure whatever scene or element the page requests, so a static return value would break the page.

Instead, anti-fingerprinting browsers use a technique called farbling: adding tiny, consistent adjustments (for example, flipping the lowest bit of a color channel or shifting a text width by a hundred-thousandth of a pixel) that remain imperceptible on screen but change the resulting hash.

When you test a farbled browser on a fingerprint scanner such as BrowserLeaks, BrowserScan, or ToDetect, the scanner checks its database of past visitors and reports that your canvas hash is 100% unique.

At first glance, a “100% unique” score looks like a problem — normally, a unique fingerprint makes a browser easy to track. However, a unique hash only helps trackers if it stays the same across profiles and websites. If every browser profile and every website receives a different hash, a tracker cannot connect those visits to the same machine.

To break tracking without being flagged by anti-bot scripts, our adjustments must follow three rules:

  1. Calculate the adjustment seed from both the browser session and the current website’s domain name so two profiles or two websites in the same profile produce different hashes.
  2. Keep the seed deterministic within a page visit so repeated reads of the same canvas on the same site return the exact same hash.
  3. Leave no side effects that anti-bot scripts check for, such as modified Function.prototype.toString() output, broken integer element widths, or unpatched sandboxed iframes.

Step 1: Create the Manifest V3 Extension 

By default, Chromium runs extension content scripts inside an ISOLATED execution world. Scripts in the isolated world share the page’s DOM tree, but they have their own separate JavaScript window and prototype objects. If you override HTMLCanvasElement.prototype.toDataURL in the isolated world, scripts on the web page still call the original, unpatched method in the MAIN world.

To intercept prototype methods on the page’s own window, we configure the extension’s manifest.json with "world": "MAIN" and "run_at": "document_start":

{
  "manifest_version": 3,
  "name": "Fuzio Fingerprint Shield",
  "version": "1.0.0",
  "description": "Reduces 2D graphics and layout fingerprinting.",
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["content.js"],
      "run_at": "document_start",
      "world": "MAIN",
      "all_frames": true,
      "match_about_blank": true,
      "match_origin_as_fallback": true
    }
  ]
}

Each flag in content_scripts closes a specific fingerprinting gap:

  • "run_at": "document_start" runs content.js before Chromium parses the page’s DOM or executes any <script> tag.
  • "world": "MAIN" executes content.js directly inside the page’s JavaScript context.
  • "all_frames": true, "match_about_blank": true, and "match_origin_as_fallback": true ensure the script also runs inside nested frames, about:blank popups, and data: or blob: URLs.

Step 2: Derive a Per-Profile and Per-Domain Seed 

In content.js, we wrap the script in an Immediately Invoked Function Expression ((() => { ... })()). Because the script runs in the MAIN world, isolating our state and helpers inside a closure prevents leaking globals into the page’s JavaScript scope.

Inside that closure, we derive a deterministic 32-bit seed (DOMAIN_SESSION_SEED) by combining two values:

  1. Generate a random 32-bit integer once per browser session with crypto.getRandomValues and store it in sessionStorage so page reloads on the same site keep the same seed.
  2. Convert window.location.hostname into a 32-bit integer with a string hash helper (fnv1aHash) and mix it with the session seed.

Using the MurmurHash3 32-bit finalizer (fmix32) (mixHash), we derive a 1-bit pixel toggle (computeNoiseBit) and a signed sub-pixel offset (computeFloatNoise) scaled by SUBPIXEL_NOISE_STEP. We define SUBPIXEL_NOISE_STEP from Chromium’s layout unit (BLINK_LAYOUT_UNIT_PX = 1 / 64) so it satisfies two boundaries:

  • Blink’s LayoutUnit snaps element coordinates to 1 / 64 of a pixel. Dividing that unit by 1024 keeps the noise a thousand times smaller than Blink’s layout grid, so text never shifts or wraps onto a new line.
  • While TextMetrics and DOMRectReadOnly use 64-bit numbers, SVGRect (getBBox()) uses 32-bit floats with fewer decimal places. A step of (1 / 64) / 1024 is large enough to survive 32-bit float rounding.
(() => {
    const BLINK_LAYOUT_UNIT_PX = 1 / 64;
    const SUBPIXEL_NOISE_STEP = BLINK_LAYOUT_UNIT_PX / 1024;
    const MURMUR3_FMIX_C1 = 0x85ebca6b;
    const MURMUR3_FMIX_C2 = 0xc2b2ae35;

    // MurmurHash3 32-bit finalizer (fmix32) to mix an input with the seed.
    function mixHash(value, seed) {
        let state = Math.imul(value ^ seed, MURMUR3_FMIX_C1);
        state = Math.imul(state ^ (state >>> 13), MURMUR3_FMIX_C2);
        return (state ^ (state >>> 16)) >>> 0;
    }

    function deriveDomainSessionSeed(win) {
        const sessionSeed = getOrCreateSessionSeed(win);
        const hostHash = fnv1aHash(win.location.hostname || "local");
        return mixHash(hostHash, sessionSeed);
    }

    function computeNoiseBit(index, seed) {
        return mixHash(index, seed) & 1;
    }

    function computeFloatNoise(value, seed) {
        // Convert the decimal measurement to an integer key for mixHash.
        const key = Math.round(value * 1000);
        // Extract one byte (0..255) from bits 8..15 of the 32-bit hash.
        const byteVal = (mixHash(key, seed) >>> 8) & 0xff;
        // Shift 0..255 to -128..+127 so noise can be positive or negative.
        const offset = byteVal - 128;
        // Replace 0 with 1 so every measurement is perturbed.
        const nonZeroOffset = offset === 0 ? 1 : offset;
        return nonZeroOffset * SUBPIXEL_NOISE_STEP;
    }
    // ...
})();

Step 3: Farble 2D Canvas and OffscreenCanvas Pixels 

With computeNoiseBit in place, we can now perturb our first fingerprinting surface: 2D canvas bitmaps. Once a page finishes drawing on a 2D canvas, fingerprinting scripts extract the rendered bitmap through two types of APIs:

  • CanvasRenderingContext2D.prototype.getImageData() returns an ImageData object containing a Uint8ClampedArray of R, G, B, A bytes (0 to 255) for every pixel.
  • HTMLCanvasElement.prototype.toDataURL() and HTMLCanvasElement.prototype.toBlob() compress the canvas bitmap into a PNG, JPEG, or WebP image and return a Base64 string or binary Blob.

Intercepting HTMLCanvasElement and CanvasRenderingContext2D 

To perturb both extraction paths without altering the page’s visible canvas, we handle each case in patchCanvas2D:

  • When a script calls getImageData(), XOR every 16th byte (one color channel in every fourth pixel) with computeNoiseBit(i, seed).
  • When a script calls toDataURL() or toBlob(), copy the original bitmap onto a temporary off-screen <canvas>, apply applyPixelNoise to the copy, and serialize the copy so noise never accumulates on the page’s live canvas.
function applyPixelNoise(imageData, seed) {
    const data = imageData.data;
    for (let i = 0; i < data.length; i += 16) {
        data[i] = data[i] ^ computeNoiseBit(i, seed);
    }
    return imageData;
}

function cloneWithNoise(canvas, seed) {
    const clone = canvas.ownerDocument.createElement("canvas");
    clone.width = canvas.width;
    clone.height = canvas.height;
    const ctx = clone.getContext("2d");
    ctx.drawImage(canvas, 0, 0);
    const pixels = ctx.getImageData(0, 0, clone.width, clone.height);
    ctx.putImageData(applyPixelNoise(pixels, seed), 0, 0);
    return clone;
}

function patchCanvas2D(win, seed) {
    const ctxProto = win.CanvasRenderingContext2D.prototype;
    const canvasProto = win.HTMLCanvasElement.prototype;
    const origGetImageData = ctxProto.getImageData;
    const origToDataURL = canvasProto.toDataURL;
    const origToBlob = canvasProto.toBlob;

    ctxProto.getImageData = function (sx, sy, sw, sh, settings) {
        const pixels = origGetImageData.call(this, sx, sy, sw, sh, settings);
        return applyPixelNoise(pixels, seed);
    };

    canvasProto.toDataURL = function (...args) {
        return origToDataURL.apply(cloneWithNoise(this, seed), args);
    };

    canvasProto.toBlob = function (callback, type, quality) {
        return origToBlob.call(
            cloneWithNoise(this, seed), callback, type, quality
        );
    };
}

Intercepting OffscreenCanvas 

Chromium also provides OffscreenCanvas, which renders 2D graphics in memory without a DOM node and uses its own separate prototypes (OffscreenCanvas.prototype and OffscreenCanvasRenderingContext2D.prototype). In patchOffscreenCanvas, we apply the same applyPixelNoise and off-screen cloning wrapper to OffscreenCanvasRenderingContext2D.prototype.getImageData and OffscreenCanvas.prototype.convertToBlob so HTMLCanvasElement and OffscreenCanvas hashes stay consistent.

Step 4: Perturb Sub-Pixel Text, SVG, and DOM Layout Metrics 

Fingerprinting scripts can also identify the operating system’s font engine without reading canvas pixels by measuring text widths and layout boxes in JavaScript.

Farbling All Seven TextMetrics Properties 

Calling ctx.measureText("Cwm fjordbank glyphs vext quiz") on a 2D canvas returns a TextMetrics object that exposes both the advance width and six glyph bounding-box getters. In patchCanvasTextMetrics, we wrap all seven getters on TextMetrics.prototype, keeping 0 unchanged (such as for an empty string) and adding computeFloatNoise to non-zero values:

function patchCanvasTextMetrics(win, seed) {
    const metricsProto = win.TextMetrics.prototype;
    const properties = [
        "width",
        "actualBoundingBoxLeft",
        "actualBoundingBoxRight",
        "actualBoundingBoxAscent",
        "actualBoundingBoxDescent",
        "fontBoundingBoxAscent",
        "fontBoundingBoxDescent"
    ];

    for (const prop of properties) {
        const origGetter = Object.getOwnPropertyDescriptor(
            metricsProto, prop
        ).get;
        Object.defineProperty(metricsProto, prop, {
            get() {
                const val = origGetter.call(this);
                return val === 0 ? 0 : val + computeFloatNoise(val, seed);
            }
        });
    }
}

Perturbing SVG Text and Bounding Boxes 

Trackers also measure font rendering without using Canvas by creating a hidden <svg><text> element and reading its advance width and bounding box. In patchSvgTextMetrics, we wrap both SVG measurement methods and add computeFloatNoise to non-zero dimensions:

function patchSvgTextMetrics(win, seed) {
    const svgTextProto = win.SVGTextContentElement.prototype;
    const svgGraphicsProto = win.SVGGraphicsElement.prototype;
    const origGetLength = svgTextProto.getComputedTextLength;
    const origGetBBox = svgGraphicsProto.getBBox;

    svgTextProto.getComputedTextLength = function () {
        const len = origGetLength.call(this);
        return len === 0 ? 0 : len + computeFloatNoise(len, seed);
    };

    svgGraphicsProto.getBBox = function (...args) {
        const box = origGetBBox.apply(this, args);
        if (box.width > 0) box.width += computeFloatNoise(box.width, seed);
        if (box.height > 0) box.height += computeFloatNoise(box.height, seed);
        return box;
    };
}

Perturbing Fractional DOMRects Without Breaking Integer Layouts 

Finally, fingerprinting scripts measure inline HTML elements and text selections using getBoundingClientRect() and getClientRects() on Element.prototype and Range.prototype.

When adding noise to DOMRect dimensions, we skip whole-number layout boxes for two reasons:

  • Standard page containers (such as document.body) have whole-number pixel widths like 1280, which scripts compare against integer properties like document.body.clientWidth.
  • Font-measurement elements created by fingerprinters have decimal pixel dimensions (such as 129.53125).

By checking !Number.isInteger(rect.width) and !Number.isInteger(rect.height) before adding noise, we perturb sub-pixel font measurements while keeping whole-number page layouts intact:

function perturbRectIfFractional(rect, seed) {
    if (rect.width > 0 && !Number.isInteger(rect.width)) {
        rect.width += computeFloatNoise(rect.width, seed);
    }
    if (rect.height > 0 && !Number.isInteger(rect.height)) {
        rect.height += computeFloatNoise(rect.height, seed);
    }
    return rect;
}

function patchDomRectMetrics(win, seed) {
    for (const proto of [win.Element.prototype, win.Range.prototype]) {
        const origGetBounding = proto.getBoundingClientRect;
        const origGetRects = proto.getClientRects;

        proto.getBoundingClientRect = function () {
            return perturbRectIfFractional(origGetBounding.call(this), seed);
        };

        proto.getClientRects = function () {
            const list = origGetRects.call(this);
            for (const rect of list) perturbRectIfFractional(rect, seed);
            return list;
        };
    }
}

Step 5: Prevent Detection and Sandboxed Iframe Bypasses 

If you load the extension into Chromium right now and open BrowserLeaks Canvas, the reported hash will still match your unpatched hardware baseline. Real-world fingerprinting suites use two techniques to detect or bypass prototype overrides in the main window:

  1. Scripts call HTMLCanvasElement.prototype.toDataURL.toString() to check whether the method returns "function toDataURL() { [native code] }" or exposes custom JavaScript wrapper code.
  2. Sites like BrowserLeaks place <iframe sandbox="allow-same-origin"> in the DOM without the allow-scripts flag. Omitting allow-scripts blocks extension content_scripts inside the iframe, while allow-same-origin lets the parent page call iframe.contentDocument.createElement("canvas") and run the child frame’s unpatched toDataURL() method.

Masking Function.prototype.toString 

Whenever we replace a built-in method, we save its original "[native code]" string in a map (maskedFunctions). We then override Function.prototype.toString to return that saved string for any patched function:

// Called for every wrapper, e.g. maskFunction(win, wrapperFn, origFn).
function maskFunction(win, patchedFn, originalFn) {
    const origToString = win.Function.prototype.toString;
    maskedFunctions.set(patchedFn, origToString.call(originalFn));
}

function patchFunctionToString(win) {
    const proto = win.Function.prototype;
    const origToString = proto.toString;
    const patchedToString = function toString() {
        return maskedFunctions.has(this)
            ? maskedFunctions.get(this)
            : origToString.call(this);
    };
    // Also mask our custom toString function itself.
    maskedFunctions.set(patchedToString, origToString.call(origToString));
    Object.defineProperty(proto, "toString", {
        value: patchedToString,
        configurable: true,
        writable: true
    });
}

Patching Sandboxed Same-Origin Iframes 

Each <iframe> creates its own JavaScript realm — a separate Window object with its own unpatched prototypes. To close the sandboxed iframe bypass, we wrap the contentWindow and contentDocument getters on HTMLIFrameElement.prototype so accessing either getter runs applyAllTechniques on the child Window before returning it:

function patchSandboxedIframes(win, applyRealmPatches) {
    const iframeProto = win.HTMLIFrameElement.prototype;
    const origWinGetter = Object.getOwnPropertyDescriptor(
        iframeProto, "contentWindow"
    ).get;
    const origDocGetter = Object.getOwnPropertyDescriptor(
        iframeProto, "contentDocument"
    ).get;

    Object.defineProperty(iframeProto, "contentWindow", {
        get() {
            const childWin = origWinGetter.call(this);
            if (childWin) applyRealmPatches(childWin);
            return childWin;
        }
    });

    Object.defineProperty(iframeProto, "contentDocument", {
        get() {
            const childWin = origWinGetter.call(this);
            if (childWin) applyRealmPatches(childWin);
            return origDocGetter.call(this);
        }
    });
}

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);
    patchSandboxedIframes(targetWindow, applyAllTechniques);
    patchFunctionToString(targetWindow);
}

applyAllTechniques(window);

That completes content.js; we are now ready to package the extension and load it into Fuzio.

Step 6: Package the Extension as CRX3 and Launch Fuzio 

Fuzio installs Chromium extensions from packaged .crx files via Profile.extensions().install(Path). Unlike standard Chrome, Fuzio does not require Chrome Web Store publisher proof in the CRX header, so CrxPacker.packExtensionToTempCrx() (included in the companion repository) zips the extension directory at startup, signs it with an ephemeral RSA-2048 keypair using standard JDK java.security APIs, and prepends the 12-byte "Cr24" CRX3 header.

To compare the results side by side, we create a single Fuzio Engine and two isolated browser profiles:

  • profiles.defaultProfile() serves as the unpatched baseline profile.
  • profiles.newProfile("FingerprintShieldProfile") serves as the protected profile where we install the .crx archive returned by CrxPacker.packExtensionToTempCrx().

We then embed a Swing BrowserView for each profile inside a JSplitPane and navigate both browsers to https://browserleaks.com/canvas:

public static void main(String[] args) {
    var engine = Engine.newInstance(HARDWARE_ACCELERATED);
    var profiles = engine.profiles();

    var baselineProfile = profiles.defaultProfile();
    var protectedProfile = profiles.newProfile("FingerprintShieldProfile");

    var crxPath = CrxPacker.packExtensionToTempCrx();
    protectedProfile.extensions().install(crxPath);

    var baselineBrowser = baselineProfile.newBrowser();
    var protectedBrowser = protectedProfile.newBrowser();

    invokeLater(() -> {
        var splitPane = new JSplitPane(
                JSplitPane.HORIZONTAL_SPLIT,
                BrowserView.newInstance(baselineBrowser),
                BrowserView.newInstance(protectedBrowser)
        );
        splitPane.setResizeWeight(0.5);

        var frame = new JFrame("Fuzio Fingerprint Shield Comparison");
        frame.add(splitPane, BorderLayout.CENTER);
        frame.setSize(1400, 820);
        frame.setVisible(true);

        var testUrl = "https://browserleaks.com/canvas";
        baselineBrowser.navigation().loadUrl(testUrl);
        protectedBrowser.navigation().loadUrl(testUrl);
    });
}

Results and Demonstration 

Run the application with Gradle, replacing <YOUR_LICENSE_KEY> with your Fuzio license key:

./gradlew run -Dfuzio.license.key=<YOUR_LICENSE_KEY>

The application opens two BrowserView panes side by side on BrowserLeaks Canvas. Comparing the default profile (No Extension) against two isolated profiles running our extension shows that every 2D graphics and layout vector produces a different value per profile, repeats identically on a second call within the same page visit, and leaves whole-number layout dimensions untouched:

SurfaceNo ExtensionProfile 1 (1st Call)Profile 1 (2nd Call)Profile 2 (1st Call)
Canvas hash2F315868...331F79AA...331F79AA...A33EE872...
OffscreenCanvas4207f105cf8ae174cf8ae17440882f35
TextMetrics196.86132196.86133196.86133196.86131
SVG.getBBox()119.57812119.57858119.57858119.57744
DOMRect (float)129.53125129.53126129.53126129.53124
DOMRect (int)1280128012801280

You can find the complete runnable project in the Gitee repository.

Conclusion 

In Part 1 of this series, we built a Manifest V3 extension in Fuzio that applies deterministic per-domain noise across 2D canvas bitmaps, TextMetrics, SVG text, and fractional DOMRect boxes. By masking Function.prototype.toString(), patching sandboxed iframes on access, and packaging the extension as a CRX3 archive at startup, each Fuzio Profile produces its own consistent 2D fingerprint without breaking page layouts.

In the next part of the series, we will protect 3D GPU pipelines, shaders, and display properties across WebGL, WebGL2, WebGPU, window.screen, and high-entropy CSS media queries.

Add a Chromium-based browser engine to your Java desktop app with Fuzio.

Try for free