ShardBrowser icon indicating copy to clipboard operation
ShardBrowser copied to clipboard

Canvas noise is applied to toDataURL() but not to getImageData(): the two disagree, which makes the noise detectable

Open angeloathayde opened this issue 2 months ago • 1 comments

Environment: ShardX Launcher 2.0.1, engine 152.0.7977.65 build 2, Windows 11 x64, noise.canvas.enabled=true with a seed < 2^31.

Symptom: for the same drawing, the pixels decoded from toDataURL() differ from getImageData() on the source canvas. PNG is lossless, so without noise the round-trip is pixel-identical (verified with noise off: 0 mismatches).

Probe (CDP, https://example.com):

const draw = (c) => { c.width = 240; c.height = 60; const x = c.getContext('2d', { willReadFrequently: true });
  x.textBaseline = 'top'; x.font = "14px 'Arial'"; x.fillStyle = '#f60'; x.fillRect(125, 1, 62, 20);
  x.fillStyle = '#069'; x.fillText('Cwm fjordbank glyphs vext quiz, \u{1F600}', 2, 15);
  x.fillStyle = 'rgba(102,204,0,0.7)'; x.fillText('Cwm fjordbank glyphs vext quiz', 4, 17); return x; };
const a = document.createElement('canvas'); const raw = draw(a).getImageData(0, 0, 240, 60).data;
const img = new Image(); await new Promise((r) => { img.onload = r; img.src = a.toDataURL(); });
const b = document.createElement('canvas'); b.width = 240; b.height = 60;
const xb = b.getContext('2d', { willReadFrequently: true }); xb.drawImage(img, 0, 0);
const rt = xb.getImageData(0, 0, 240, 60).data;
let diff = 0; for (let i = 0; i < raw.length; i += 4) if (raw[i] !== rt[i] || raw[i+1] !== rt[i+1] || raw[i+2] !== rt[i+2] || raw[i+3] !== rt[i+3]) diff++;
noise.canvas mismatched pixels / 14400
off 0
on (any valid seed) 2

getImageData() itself is stable across repeated draws (0 differences), so the raw path is deterministic and un-noised while the export path is noised.

Impact: comparing toDataURL() against getImageData() (or against toBlob()) is a standard anti-tampering check; a non-zero difference identifies a canvas-noising browser even though each individual hash looks natural.

Expected: apply the same deterministic per-profile perturbation on every read-back path (getImageData, toDataURL, toBlob, createImageBitmap, WebGL readPixels) so the outputs agree with each other.

angeloathayde avatar Sep 11 '26 18:09 angeloathayde

in v2.0.3

ProxyShard avatar Sep 13 '26 12:09 ProxyShard