Language Fingerprinting

Background

Browser language properties have been used as a device fingerprint element since fingerprinting has existed. While it's relatively generic there are a few interesting features that make it useful. The de facto standard has been to use the language property to return the browser language, and up until recently Microsoft's Internet Explorer did not use this. Instead, IE gave you options for system, user and browser settings. Current versions of Edge now support the language property, but will also return the legacy properties. This will allow you to distinguish browsers even if the user-agent has been modified.

How It Works

In order to get the best print possible from languages we'll have to make several calls in order to capture as much entropy as possible. It is also important to pay attention to the case of the returned data as that can give you additional entropy. Below we'll define the properties available.

The language property returns the language version of the browser. It should be noted that this is not impacted by the setting within the browser, but by the installation selection. This is supported by all major browsers with the exception if IE 10 and lower.

The languages property returns a string of supported languages, while the above language property only provides the first in the list. This is supported by all major browsers with the exception of Safari 8 and lower, and Microsoft Explorer.

There are three additional properties that are proprietary to Microsoft, and are returned in all versions of their browsers. They are userlanguage, browserlanguage and systemlanguage. The userlanguage property reflects the setting in the Regional Options under control panel. The browserlanguage property reflects the language of the operating system regardless of the installed version of Windows Internet Explorer. The systemlanguage property reflects the language edition of the installed operating system.

Entropy Estimate: 10.1 bits

Code

The javascript function below fingerprints the browser languages. 

Source Code

function fp_languages() {

    "use strict";

    var strSep, strOnError, strLang, strOut;

 

    strSep = "|";

    strOnError = "Error";

    strLang = "";

    strOut = "";

 

    try {

        if (navigator.language) {

            strLang = "lang=" + navigator.language + strSep;

        } else {

            strLang = "lang=" + "undefined" + strSep;

        }

        if (navigator.languages) {

        strLang = strLang + "langs=" + navigator.languages + strSep;

    } else {

        strLang = strLang + "langs=" + "undefined" + strSep;

        }

        // Microsoft specific properties

        if (navigator.browserLanguage) {

            strLang = strLang + "brlang=" + navigator.browserLanguage + strSep;

        } else {

            strLang = strLang + "brlang=" + "undefined" + strSep;

        }

        if (navigator.systemLanguage) {

            strLang = strLang + "syslang=" + navigator.systemLanguage + strSep;

        } else {

            strLang = strLang + "syslang=" + "undefined" + strSep;

        }

        if (navigator.userLanguage) {

            strLang = strLang + "usrlang=" + navigator.userLanguage;

        } else {

            strLang = strLang + "usrlang=" + "undefined";

        }

        strOut = strLang;

        return strOut;

    } catch (err) {

        return strOnError;

    }

}

Validation

Unlike other code on the Internet we do everything possible to verify our code for you. In order to minimize problems and maximize compatibility this code has been verified with JSLint and has been extensively tested with over 1100 OS/Browser combinations using BrowserStack.

Reference

NavigatorLanguage.language (Jun 30, 2017). In MDN web docs. Retrieved September 01, 2017, from https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language

NavigatorLanguage.languages (May 11, 2017). In MDN web docs. Retrieved September 01, 2017, from https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/languages

browserLanguage property (n.d.). In Microsoft Developer Network. Retrieved September 01, 2017, from https://msdn.microsoft.com/en-us/library/ms533542(v=vs.85).aspx

systemLanguage property (n.d.). In Microsoft Developer Network. Retrieved September 01, 2017, from https://msdn.microsoft.com/en-us/library/ms534653(v=vs.85).aspx

userLanguage property (n.d.). In Microsoft Developer Network. Retrieved September 01, 2017, from https://msdn.microsoft.com/en-us/library/ms534713(v=vs.85).aspx