question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable Keyboard API fingerprinting

See original GitHub issue

Description

Brave inherits from Chrome implementation of Keyboard API which does not provide any functionality to the user (only Chrome and Opera support it and, to my knowledge, no site actually uses it). However, the API might be used for fingerprinting.

WICG Keyboard Map Draft mentions that the API can be used for fingerprinting of:

  • Users who use uncommon ASCII layouts (like Dvorak or Colemak)
  • Users who use an ASCII layout that doesn’t match the default for the region that they are in. For example, a user in the US with an active UK or French layout.

Steps to Reproduce

  1. Verify that “Shields” are on
  2. Enable a few different keyboards in your OS, e.g. Dvorak (DV):
  3. Run this in the console and observe the output with different keyboard layouts:
    var keyboard = {}
    navigator.keyboard.getLayoutMap()
    .then(keyboardLayoutMap => {
      keyboardLayoutMap.forEach((value,key,map) => {keyboard[key] = value})
      console.log(keyboard)
    })
    

Actual result:

For standard English keyboard:

{KeyE: "e", KeyD: "d", Minus: "-", KeyH: "h", KeyZ: "z", ...}

For Dvorak keyboard:

{KeyE: ".", KeyD: "e", Minus: "[", KeyH: "d", KeyZ: ";", ...}

For Colemak keyboard:

Expected result:

When Shields are on, either API should be unavailable ()

Reproduces how often:

Easily reproduced

Brave version (brave://version info)

All versions of Brave based on Chromium 63 and above.

Brave 0.61.52 Chromium: 73.0.3683.86 (Official Build) (64-bit)
Revision f9b0bec6063ea50ce2b71f5b9abbae7beee319a6-refs/branch-heads/3683@{#858}
OS Windows 10 OS Build 17763.379

Reproducible on current release:

  • Does it reproduce on brave-browser dev/beta builds? Reproducible on Beta build
Brave 0.62.37 Chromium: 73.0.3683.86 (Official Build) beta (64-bit)
Revision f9b0bec6063ea50ce2b71f5b9abbae7beee319a6-refs/branch-heads/3683@{#858}
OS Windows 10 OS Build 17763.379

Additional Information

Compatibility impact is minimal

Keyboard API was only recently introduced and only in Chrome 68 and Opera 55 (according to MDN). It should be trivial to remove or polyfill. A good candidate for dummy values is provided in the official polyfill: https://github.com/WICG/keyboard-map/blob/master/keyboard-polyfill.js

Note that navigator.keyboard also includes navigator.keyboard.lock defined in Keybard Lock API – a related API introduced at the same time (and apparently with similarly small adoption).

WICG Keyboard Map Draft recommendations

Excerpt from here:

6.1. Privacy Mitigations User agents that are concerned about the privacy impact of providing this keyboard mapping information can also consider the following mitigations:

Having a user prompt to ask for permission whenever a site attempts to use this API.

Always return a “standard” mapping. Although note that the standard mapping would need to vary for different parts of the world. For example, a user agent that had a “privacy mode” that always returned a US-QWERTY layout mapping would actually be providing more identifying information for users in the UK than the actual mapping would (since most users in the UK do not use a US layout).

6.2. Privacy Mode If a user agent provides an “incognito” or “privacy mode”, then this API should act the same as it does outside of “privacy mode”. The reason for this is that there is no universal neutral value that can be returned to ensure the user’s privacy.

User agents may choose to give the user the option to specify what value should be returned when in this mode, although care must be taken to ensure that the user does not get a false sense of security since this value would need to be updated when if they travel outside their home region.

Links

WICG Keyboard Map Draft

Edit: Copied full version string; in demo code changed let to var so that you can easily run the same code many times; added a link and fixed list number.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mkarolincommented, Nov 16, 2021

QA Test Plan:

  1. Start Brave and navigate to a HTTPS site (e.g. https://brave.com)
  2. Open the Shields panel in Advanced view and verify that Fingerprinting is set to blocked (standard).
  3. Open Developer Tools -> Console
  4. Paste the following code into the console and execute it:
var keyboard = {}
navigator.keyboard.getLayoutMap()
.then(keyboardLayoutMap => {
  keyboardLayoutMap.forEach((value,key,map) => {keyboard[key] = value})
  console.log(keyboard)
})
  1. Expected result:
VM81:2 Uncaught TypeError: Cannot read properties of null (reading 'getLayoutMap')
    at <anonymous>:2:20
  1. Open the Shields panel in Advanced view and change Fingerprinting setting to Allow all fingerprinting
  2. Repeat steps 3-4
  3. Expected result:
Promise {<pending>}
VM123:5 {KeyE: 'e', KeyD: 'd', Minus: '-', KeyH: 'h', KeyZ: 'z', …}
0reactions
stephendonnercommented, Dec 21, 2021

Verified PASSED using Brave 1.34.68, Chromium 97.0.4692.56 on a Google Pixel XL running Android 9.0.

example example example example
Screenshot_20211221-132258 Screen Shot 2021-12-21 at 1 22 27 PM Screenshot_20211221-132307 Screen Shot 2021-12-21 at 1 23 48 PM
Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Chrome 97 introduces controversial keyboard API
As I've noted in person a while ago, the Keyboard Map API as proposed exposes a high entropy fingerprinting surface.
Read more >
Chrome 97 relaxes privacy protections to help out Microsoft ...
Google Chrome 97 arrived on Tuesday, bringing with it a Microsoft-backed keyboard API rejected by Apple and Mozilla on privacy grounds.
Read more >
Device Fingerprinting API Guide - Sift Science
Learn how to create custom events, send historical data, fight multiple fraud and abuse types, and automate your fraud decisions.
Read more >
Fingerprinting Explained: How It Works & How To Block It
Can I block fingerprinting? ... Yes. There is one way and one way only you can do this: you can spoof, i.e., make...
Read more >
Enabling and Disabling Fingerprinting During Scans
Uncheck the Enable Fingerprinting Box. A pop up will appear. Select Yes to confirm your intention to uncheck the box and disable Fingerprinting....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found