Canvas Fingerprinting

The Canvas API, which is designed for drawing graphics via JavaScript and HTML, can also be used for online tracking via browser fingerprinting. This technique relies on variations in how canvas images are rendered on different web browsers and platforms to create a personalized digital fingerprint of a user's browser.

JavaScript Disabled

Canvas Support Detection

Canvas 2D API True
Text API for Canvas True
Canvas toDataURL True

Canvas Fingerprint

Signaturec5c44342f895e9a18925506eccb0e451
Uniqueness99.97% (72 of 227965 user agents have the same signature)

Image File Details

 Error displaying <img> tag
File Size6534 bytes
Number of Colors689
PNG Headers

Chunk

Length

CRC

Content

IHDR13477a703e
PNG image header: 220x30, 8 bits/sample, truecolor+alpha, noninterlaced
sRGB1aece1ce9
sRGB color space, rendering intent: Perceptual
IDAT6464877b5afe
PNG image data
IEND0ae426082
end-of-image marker

Signature Stats

It's very likely that your web browser is Chrome and your operating system is Windows.

Operating Systems

Browsers

Devices

Windows 1034/72Chrome39/72Desktop59/72
GNU/Linux26/72Headless Chrome15/72Apple6/72
Mac 10.154/72Microsoft Edge8/72Apple iPhone4/72
iOS 10.31/72Safari5/72Samsung Galaxy A03s2/72
Android 71/72Firefox4/72Samsung Galaxy S71/72

Engines

Browsers by Version

Platforms

Blink 1206/72Chrome 1305/72Linux x86_6464/72
WebKit 605.1.154/72Chrome 1205/72Win326/72
Blink 1273/72Headless Chrome 1254/72iPhone1/72
Blink 1173/72Chrome 1284/72Linux aarch641/72
Blink 1303/72Chrome 1173/72

How Canvas Fingerprinting Works

The way an image is rendered on a canvas can vary based on the web browser, operating system, graphics card, and other factors, resulting in a unique image that can be used to create a fingerprint. The way that text is rendered on a canvas can also vary based on the font rendering settings and anti-aliasing algorithms used by different web browsers and operating systems.

This small animated GIF illustrates the variability of canvas images among 35 different users. Although the JavaScript code remains the same, each frame is distinct due to differences in how the images are rendered on different systems:

Canvas Fingerprinting

Here is the JavaScript code that creates our image:

  1. // Text with lowercase/uppercase/punctuation symbols
  2. var txt = "BrowserLeaks,com <canvas> 1.0";
  3. ctx.textBaseline = "top";
  4. // The most common type
  5. ctx.font = "14px 'Arial'";
  6. ctx.textBaseline = "alphabetic";
  7. ctx.fillStyle = "#f60";
  8. ctx.fillRect(125,1,62,20);
  9. // Some tricks for color mixing to increase the difference in rendering
  10. ctx.fillStyle = "#069";
  11. ctx.fillText(txt, 2, 15);
  12. ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
  13. ctx.fillText(txt, 4, 17);

To generate a signature from the canvas, we need to extract the pixels from the application's memory by calling the toDataURL() function. This function returns a base64-encoded string representing the binary image file. We can then compute an MD5 hash of this string to obtain the canvas fingerprint. Alternatively, we could extract the CRC checksum from the IDAT chunk, which is located 16 to 12 bytes from the end of every PNG file, and use it as our canvas fingerprint.

Further Reading

Leave a Comment (307)