Bug 1693295 - Cap the Windows version in the User-Agent to 10.0. r=cpeterson
authorHenri Sivonen <hsivonen@hsivonen.fi>
Mon, 22 Feb 2021 08:56:40 +0000
changeset 568179 3b60746765d32fc72dcbc1e37efbe5cb77fd1082
parent 568178 8f0413b1ad6f1c3ebfa951e49f0a08a9f6e8a644
child 568180 d6efdab9e842bdbd57d29d2b5ada0e3041fe04c0
push id38228
push usernerli@mozilla.com
push dateMon, 22 Feb 2021 17:34:52 +0000
treeherdermozilla-central@aefea952b697 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson
bugs1693295
milestone87.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1693295 - Cap the Windows version in the User-Agent to 10.0. r=cpeterson Differential Revision: https://phabricator.services.mozilla.com/D105605
browser/components/resistfingerprinting/test/browser/browser_navigator.js
netwerk/protocol/http/nsHttpHandler.cpp
--- a/browser/components/resistfingerprinting/test/browser/browser_navigator.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_navigator.js
@@ -65,16 +65,20 @@ const DEFAULT_PLATFORM = {
 const SPOOFED_PLATFORM = {
   linux: "Linux x86_64",
   win: "Win32",
   macosx: "MacIntel",
   android: "Linux aarch64",
   other: "Linux x86_64",
 };
 
+// If comparison with this value fails in the future,
+// it's time to evaluate if exposing a new Windows
+// version to the Web is appropriate. See
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1693295
 const WindowsOscpu =
   cpuArch == "x86_64"
     ? `Windows NT ${osVersion}; Win64; x64`
     : `Windows NT ${osVersion}`;
 
 const DEFAULT_OSCPU = {
   linux: `Linux ${cpuArch}`,
   win: WindowsOscpu,
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -946,16 +946,28 @@ void nsHttpHandler::InitUserAgentCompone
   // Gather OS/CPU.
 #  if defined(XP_WIN)
   OSVERSIONINFO info = {sizeof(OSVERSIONINFO)};
 #    pragma warning(push)
 #    pragma warning(disable : 4996)
   if (GetVersionEx(&info)) {
 #    pragma warning(pop)
 
+    if (info.dwMajorVersion >= 10) {
+      // Cap the reported Windows version to 10.0. This way, Microsoft doesn't
+      // get to change Web compat-sensitive values without our veto. The
+      // compat-sensitivity keeps going up as 10.0 stays as the current value
+      // for longer and longer. If the system-reported version ever changes,
+      // we'll be able to take our time to evaluate the Web compat impact
+      // instead of having to scamble to react like happened with macOS
+      // changing from 10.x to 11.x.
+      info.dwMajorVersion = 10;
+      info.dwMinorVersion = 0;
+    }
+
     const char* format;
 #    if defined _M_X64 || defined _M_AMD64
     format = OSCPU_WIN64;
 #    else
     BOOL isWow64 = FALSE;
     if (!IsWow64Process(GetCurrentProcess(), &isWow64)) {
       isWow64 = FALSE;
     }