From e70234b3501569ad5fa93c4adc47cf062226f353 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Mon, 1 Oct 2018 21:27:34 -0700 Subject: [PATCH] Bug 583181 - Part 2: Add separate definitions for LEGACY_BUILD_ID and LEGACY_UA_GECKO_TRAIL. r=hsivonen "Gecko trail" is the term used by MDN [1] for the YYYMMDD build date in the UA string's "Gecko/" token. Build ID is a YYYYMMDDHHMMSS build timestamp. Use LEGACY_BUILD_ID to spoof navigator.buildID. Use LEGACY_UA_GECKO_TRAIL to construct the UA string. [1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox Differential Revision: https://phabricator.services.mozilla.com/D7983 --HG-- extra : rebase_source : e2a4d7579d419046f0bad6290078f9a652a770d8 extra : source : 8a26c8598528722a8920513c7fdfea40aefe0dbc --- dom/base/Navigator.cpp | 4 ++-- dom/tests/mochitest/bugs/test_navigator_buildID.html | 2 +- netwerk/protocol/http/nsHttpHandler.cpp | 2 +- toolkit/components/resistfingerprinting/nsRFPService.cpp | 2 +- toolkit/components/resistfingerprinting/nsRFPService.h | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 56f6c12c9ed3..e5428a26fc19 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -456,8 +456,8 @@ Navigator::GetProduct(nsAString& aProduct) void Navigator::GetProductSub(nsAString& aProductSub) { - // Legacy build ID hardcoded for backward compatibility (bug 776376) - aProductSub.AssignLiteral(LEGACY_BUILD_ID); + // Legacy build date hardcoded for backward compatibility (bug 776376) + aProductSub.AssignLiteral(LEGACY_UA_GECKO_TRAIL); } nsMimeTypeArray* diff --git a/dom/tests/mochitest/bugs/test_navigator_buildID.html b/dom/tests/mochitest/bugs/test_navigator_buildID.html index c155264314ec..84672456ad85 100644 --- a/dom/tests/mochitest/bugs/test_navigator_buildID.html +++ b/dom/tests/mochitest/bugs/test_navigator_buildID.html @@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=583181 SimpleTest.waitForExplicitFinish(); -const LEGACY_BUILD_ID = 20100101; // Resist Fingerprinting's build ID +const LEGACY_BUILD_ID = 20181001000000; // // Access navigator.buildID from unprivileged web content. diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 5ff9c18c52d6..319e4968a855 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -516,7 +516,7 @@ nsHttpHandler::Init() #if defined(ANDROID) mProductSub.AssignLiteral(MOZILLA_UAVERSION); #else - mProductSub.AssignLiteral(LEGACY_BUILD_ID); + mProductSub.AssignLiteral(LEGACY_UA_GECKO_TRAIL); #endif #if DEBUG diff --git a/toolkit/components/resistfingerprinting/nsRFPService.cpp b/toolkit/components/resistfingerprinting/nsRFPService.cpp index 6c3f4992b2d7..9bd51b0d09d7 100644 --- a/toolkit/components/resistfingerprinting/nsRFPService.cpp +++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp @@ -707,7 +707,7 @@ nsRFPService::GetSpoofedUserAgent(nsACString &userAgent) uint32_t spoofedVersion = firefoxVersion - ((firefoxVersion - 4) % 7); userAgent.Assign(nsPrintfCString( "Mozilla/5.0 (%s; rv:%d.0) Gecko/%s Firefox/%d.0", - SPOOFED_UA_OS, spoofedVersion, LEGACY_BUILD_ID, spoofedVersion)); + SPOOFED_UA_OS, spoofedVersion, LEGACY_UA_GECKO_TRAIL, spoofedVersion)); return rv; } diff --git a/toolkit/components/resistfingerprinting/nsRFPService.h b/toolkit/components/resistfingerprinting/nsRFPService.h index c85caac6b754..97370119477b 100644 --- a/toolkit/components/resistfingerprinting/nsRFPService.h +++ b/toolkit/components/resistfingerprinting/nsRFPService.h @@ -46,7 +46,8 @@ #endif #define SPOOFED_APPNAME "Netscape" -#define LEGACY_BUILD_ID "20100101" +#define LEGACY_BUILD_ID "20181001000000" +#define LEGACY_UA_GECKO_TRAIL "20100101" // Forward declare LRUCache, defined in nsRFPService.cpp class LRUCache;