From 16f88562645b219915a94a91d23f45db1913c739 Mon Sep 17 00:00:00 2001 From: hackademix Date: Fri, 29 May 2020 00:30:28 +0200 Subject: [PATCH] Unspoofable browser version detection. --- src/bg/RequestGuard.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js index f244b3a..72d3da2 100644 --- a/src/bg/RequestGuard.js +++ b/src/bg/RequestGuard.js @@ -533,7 +533,11 @@ var RequestGuard = (() => { let filterAll = {urls: allUrls}; listen("onBeforeRequest", filterAll, ["blocking"]); - const mergingCSP = parseInt(navigator.userAgent.replace(/.*Firefox\/(\d+).*/, "$1")) >= 77; + let mergingCSP = "getBrowserInfo" in browser.runtime; + if (mergingCSP) { + let {vendor, version} = await browser.runtime.getBrowserInfo(); + mergingCSP = vendor === "Mozilla" && parseInt(version) >= 77; + } if (mergingCSP) { // In Gecko>=77 (https://bugzilla.mozilla.org/show_bug.cgi?id=1462989) // we need to cleanup our own cached headers in a dedicated listener :(