From be94c8363501bfafe44d068660a722d57cf4b140 Mon Sep 17 00:00:00 2001 From: Alexei Date: Mon, 29 Nov 2021 17:08:34 -0500 Subject: [PATCH 1/2] Remove WebRTC toggle --- doc/permissions.md | 2 - src/_locales/en_US/messages.json | 10 +--- src/js/background.js | 95 +++++++------------------------- src/js/migrations.js | 32 +++++------ src/js/options.js | 12 ---- src/js/popup.js | 27 +-------- src/js/webrequest.js | 10 ---- src/skin/options.html | 9 --- src/skin/popup.css | 10 +--- src/skin/popup.html | 13 ----- 10 files changed, 38 insertions(+), 182 deletions(-) diff --git a/doc/permissions.md b/doc/permissions.md index e520ee5ea5..ee82a13d4d 100644 --- a/doc/permissions.md +++ b/doc/permissions.md @@ -9,8 +9,6 @@ The Privacy API lets extensions modify browser-wide privacy settings. Privacy Ba - [prefetching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Link_prefetching_FAQ) (network predictions), as it presents a poor tradeoff between privacy and perceived browsing performance - suggestions for similar pages when a page can't be found, as this Chrome feature sends visited web addresses to Google -In addition, Privacy Badger allows users to set a stricter WebRTC IP handling policy in order to prevent leaking local network address information. - ## Storage The storage API lets extensions store information that persists after the browser is closed. Privacy Badger uses it to save user settings and information it has learned about trackers. diff --git a/src/_locales/en_US/messages.json b/src/_locales/en_US/messages.json index 68f8a74541..8734a55a1a 100644 --- a/src/_locales/en_US/messages.json +++ b/src/_locales/en_US/messages.json @@ -125,10 +125,6 @@ "message": "blocked", "description": "Dropdown control setting on the Tracking Domains options page tab." }, - "options_webrtc_setting": { - "message": "Prevent WebRTC from leaking local IP address", - "description": "Checkbox label on the general settings page" - }, "intro_welcome": { "message": "Privacy Badger automatically learns to block invisible trackers. Take a minute to see how.", "description": "Intro page welcome paragraph." @@ -307,10 +303,6 @@ "message": "To learn how Privacy Badger works, click below for a quick tutorial.", "description": "Second part of a reminder to visit the intro page" }, - "options_webrtc_warning": { - "message": "WebRTC can leak your local IP address. Note that enabling this option may degrade performance on web conferencing apps like Google Hangouts.", - "description": "Tooltip on the general settings page" - }, "options_general_settings": { "message": "General Settings", "description": "This is an options page tab heading." @@ -712,7 +704,7 @@ }, "deprecated_setting": { "message": "The following setting has been deprecated and will be removed in a future Privacy Badger update:", - "description": "Followed by the options_webrtc_setting message ('Prevent WebRTC...')" + "description": "Followed by the label of the deprecated setting (for example: 'Prevent WebRTC...')" }, "learn_more_link": { "message": "Visit $LINK$ to learn more.", diff --git a/src/js/background.js b/src/js/background.js index eb6a30c86c..108f594413 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -41,8 +41,6 @@ function Badger() { self.isFirstRun = false; self.isUpdate = false; - self.webRTCAvailable = checkWebRtcBrowserSupport(); - self.widgetList = []; let widgetListPromise = widgetLoader.loadWidgetsFromFile( "data/socialwidgets.json").catch(console.error); @@ -150,36 +148,6 @@ function Badger() { } }); - /** - * WebRTC availability check - */ - function checkWebRtcBrowserSupport() { - if (!(chrome.privacy && chrome.privacy.network && - chrome.privacy.network.webRTCIPHandlingPolicy)) { - return false; - } - - var available = true; - var connection = null; - - try { - var RTCPeerConnection = ( - window.RTCPeerConnection || window.webkitRTCPeerConnection - ); - if (RTCPeerConnection) { - connection = new RTCPeerConnection(null); - } - } catch (ex) { - available = false; - } - - if (connection !== null && connection.close) { - connection.close(); - } - - return available; - } - } Badger.prototype = { @@ -323,16 +291,6 @@ Badger.prototype = { (self.getSettings().getItem("disableHyperlinkAuditing") ? false : null) ); } - - // when enabled, WebRTC IP handling policy is set to Mode 3 - // https://tools.ietf.org/html/draft-ietf-rtcweb-ip-handling-01#page-5 - if (badger.webRTCAvailable) { - _set_override( - "webRTCIPHandlingPolicy", - chrome.privacy.network.webRTCIPHandlingPolicy, - (self.getSettings().getItem("preventWebRTCIPLeak") ? 'default_public_interface_only' : null) - ); - } }, /** @@ -821,7 +779,6 @@ Badger.prototype = { learnInIncognito: false, learnLocally: false, migrationLevel: 0, - preventWebRTCIPLeak: false, seenComic: false, sendDNTSignal: true, showCounter: true, @@ -885,11 +842,22 @@ Badger.prototype = { } badger.initDeprecations(); + // remove obsolete settings if (self.isUpdate) { - // remove obsolete settings - if (settings.hasItem("showTrackingDomains")) { - settings.deleteItem("showTrackingDomains"); - } + [ + "preventWebRTCIPLeak", + "showTrackingDomains", + "webRTCIPProtection", + ].forEach(item => { + if (settings.hasItem(item)) { settings.deleteItem(item); } + }); + + [ + "legacyWebRtcProtectionUser", + "showWebRtcDeprecation", + ].forEach(item => { + if (privateStore.hasItem(item)) { privateStore.deleteItem(item); } + }); } }, @@ -898,31 +866,7 @@ Badger.prototype = { * * Called on Badger startup and user data import. */ - initDeprecations: function () { - let self = this, - privateStore = self.getPrivateSettings(); - - if (!privateStore.hasItem("legacyWebRtcProtectionUser")) { - // initialize "legacy WebRTC IP leak protection user" flag - privateStore.setItem("legacyWebRtcProtectionUser", - self.getSettings().getItem("preventWebRTCIPLeak")); - - } else if (!privateStore.getItem("legacyWebRtcProtectionUser")) { - // set legacy flag to true if the IP protection gets enabled - // for whatever reason (testing, user data import) - if (self.getSettings().getItem("preventWebRTCIPLeak")) { - privateStore.setItem("legacyWebRtcProtectionUser", true); - } - } - - if (!privateStore.hasItem("showWebRtcDeprecation")) { - // will show WebRTC protection deprecation message - // iff showWebRtcDeprecation exists and is set to true - if (privateStore.getItem("legacyWebRtcProtectionUser")) { - privateStore.setItem("showWebRtcDeprecation", true); - } - } - }, + initDeprecations: function () {}, runMigrations: function() { var self = this; @@ -952,6 +896,7 @@ Badger.prototype = { Migrations.resetWebRTCIPHandlingPolicy2, Migrations.resetWebRtcIpHandlingPolicy3, Migrations.forgetOpenDNS, + Migrations.unsetWebRTCIPHandlingPolicy, ]; for (var i = migrationLevel; i < migrations.length; i++) { @@ -1007,9 +952,7 @@ Badger.prototype = { return; } - let special_page = !utils.hasOwn(self.tabData, tab_id); - - if (self.criticalError || (!special_page && badger.getPrivateSettings().getItem("showWebRtcDeprecation"))) { + if (self.criticalError) { chrome.browserAction.setBadgeBackgroundColor({tabId: tab_id, color: "#cc0000"}); chrome.browserAction.setBadgeText({tabId: tab_id, text: "!"}); return; @@ -1019,7 +962,7 @@ Badger.prototype = { // - the counter is disabled // - we don't have tabData for whatever reason (special browser pages) // - Privacy Badger is disabled on the page - if (special_page || + if (!utils.hasOwn(self.tabData, tab_id) || !self.getSettings().getItem("showCounter") || !self.isPrivacyBadgerEnabled(self.getFrameData(tab_id).host) ) { diff --git a/src/js/migrations.js b/src/js/migrations.js index 6103573a94..fbd4d1f48a 100644 --- a/src/js/migrations.js +++ b/src/js/migrations.js @@ -247,32 +247,28 @@ exports.Migrations= { resetWebRTCIPHandlingPolicy2: noop, - resetWebRtcIpHandlingPolicy3: function (badger) { - if (!badger.webRTCAvailable) { + resetWebRtcIpHandlingPolicy3: noop, + + forgetOpenDNS: (badger) => { + console.log("Forgetting Cisco OpenDNS domains ..."); + badger.storage.forget("opendns.com"); + }, + + unsetWebRTCIPHandlingPolicy: function (/*badger*/) { + if (!chrome.privacy || !chrome.privacy.network || !chrome.privacy.network.webRTCIPHandlingPolicy) { return; } - console.log("Migrating WebRTC IP protection ..."); + console.log("Unsetting webRTCIPHandlingPolicy ..."); chrome.privacy.network.webRTCIPHandlingPolicy.get({}, function (res) { - if (res.levelOfControl != 'controlled_by_this_extension') { - return; + if (res.levelOfControl == 'controlled_by_this_extension') { + chrome.privacy.network.webRTCIPHandlingPolicy.clear({ + scope: 'regular' + }); } - - // since we previously enabled this privacy override, - // update corresponding Badger setting - badger.getSettings().setItem("preventWebRTCIPLeak", true); - - // update the browser setting - // in case it needs to be migrated from Mode 4 to Mode 3 - badger.setPrivacyOverrides(); }); }, - forgetOpenDNS: (badger) => { - console.log("Forgetting Cisco OpenDNS domains ..."); - badger.storage.forget("opendns.com"); - }, - }; diff --git a/src/js/options.js b/src/js/options.js index 194b8542e7..2687dbb800 100644 --- a/src/js/options.js +++ b/src/js/options.js @@ -168,18 +168,6 @@ function loadOptions() { }); } - if (OPTIONS_DATA.webRTCAvailable && OPTIONS_DATA.legacyWebRtcProtectionUser) { - $("#webRTCToggle").show(); - $("#toggle_webrtc_mode") - .prop("checked", OPTIONS_DATA.settings.preventWebRTCIPLeak) - .on("click", function () { - updatePrivacyOverride( - "preventWebRTCIPLeak", - $("#toggle_webrtc_mode").prop("checked") - ); - }); - } - $('#local-learning-checkbox') .prop("checked", OPTIONS_DATA.settings.learnLocally) .on("click", (event) => { diff --git a/src/js/popup.js b/src/js/popup.js index 874a1fbf59..32427da70b 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -46,13 +46,6 @@ function showNagMaybe() { }, cb); } - function _setSeenWebRtcDeprecation(cb) { - chrome.runtime.sendMessage({ - type: "seenWebRtcDeprecation", - tabId: POPUP_DATA.tabId - }, cb); - } - function _hideNag() { $nag.fadeOut(); $outer.fadeOut(); @@ -133,25 +126,7 @@ function showNagMaybe() { $outer.show(); } - function _showWebRtcDeprecationPrompt() { - $('#instruction-text').hide(); - - $("#webrtc-deprecation-ack-btn").on("click", function () { - _setSeenWebRtcDeprecation(function () { - _hideNag(); - }); - }); - - $('#webrtc-deprecation-div').show(); - $('#fittslaw').hide(); - $nag.show(); - $outer.show(); - } - - if (POPUP_DATA.showWebRtcDeprecation) { - _showWebRtcDeprecationPrompt(); - - } else if (POPUP_DATA.showLearningPrompt) { + if (POPUP_DATA.showLearningPrompt) { _showLearningPrompt(); } else if (!POPUP_DATA.settings.seenComic) { diff --git a/src/js/webrequest.js b/src/js/webrequest.js index 995767fb02..4de4a61152 100644 --- a/src/js/webrequest.js +++ b/src/js/webrequest.js @@ -1243,7 +1243,6 @@ function dispatcher(request, sender, sendResponse) { origins, settings: badger.getSettings().getItemClones(), showLearningPrompt: badger.getPrivateSettings().getItem("showLearningPrompt"), - showWebRtcDeprecation: !!badger.getPrivateSettings().getItem("showWebRtcDeprecation"), tabHost: tab_host, tabId: tab_id, tabUrl: request.tabUrl, @@ -1266,10 +1265,8 @@ function dispatcher(request, sender, sendResponse) { sendResponse({ cookieblocked, - legacyWebRtcProtectionUser: badger.getPrivateSettings().getItem("legacyWebRtcProtectionUser"), origins, settings: badger.getSettings().getItemClones(), - webRTCAvailable: badger.webRTCAvailable, widgets: badger.widgetList.map(widget => widget.name), }); @@ -1308,13 +1305,6 @@ function dispatcher(request, sender, sendResponse) { break; } - case "seenWebRtcDeprecation": { - badger.getPrivateSettings().setItem("showWebRtcDeprecation", false); - badger.updateBadge(request.tabId); - sendResponse(); - break; - } - case "activateOnSite": { badger.enablePrivacyBadgerForOrigin(request.tabHost); badger.updateIcon(request.tabId, request.tabUrl); diff --git a/src/skin/options.html b/src/skin/options.html index 2f8bcb833e..2d10411dca 100644 --- a/src/skin/options.html +++ b/src/skin/options.html @@ -243,15 +243,6 @@

- diff --git a/src/skin/popup.css b/src/skin/popup.css index e7afb152c2..1b18d015bb 100644 --- a/src/skin/popup.css +++ b/src/skin/popup.css @@ -266,12 +266,9 @@ button.cta-button:hover, a.cta-button:hover { #instruction .flex-wrapper > div { padding-inline-end: 5px; } -#intro-reminder-btn, #error-message, #learning-prompt-btn, #webrtc-deprecation-ack-btn { +#intro-reminder-btn, #error-message, #learning-prompt-btn { margin-top: 1em; } -#webrtc-deprecation-ack-btn { - padding: 10px; -} #error-message { text-align: center; } @@ -295,12 +292,12 @@ button.cta-button:hover, a.cta-button:hover { margin: 0; } /* body#main to avoid applying this to options page */ -body#main #pbInstructions a, #firstparty-protections-container a, #webrtc-deprecation-div a, #donate a { +body#main #pbInstructions a, #firstparty-protections-container a, #donate a { text-decoration: underline; color: black; font-weight: bold; } -body#main #pbInstructions a:hover, #firstparty-protections-container a:hover, #webrtc-deprecation-div a:hover, #donate a:hover { +body#main #pbInstructions a:hover, #firstparty-protections-container a:hover, #donate a:hover { color: #ec9329; } #instructions-firstparty-description { @@ -566,7 +563,6 @@ div.overlay.active { /* body#main to avoid applying this to options page */ body#main #pbInstructions a, #firstparty-protections-container a, - #webrtc-deprecation-div a, #donate a, #pbInstructions, .toggle-header-title, diff --git a/src/skin/popup.html b/src/skin/popup.html index bc27eaa864..a5083f6db0 100644 --- a/src/skin/popup.html +++ b/src/skin/popup.html @@ -83,19 +83,6 @@ - -
From cfb6bbaa8ab58034cd2628944db3a7faba07d67f Mon Sep 17 00:00:00 2001 From: Alexei Date: Mon, 29 Nov 2021 17:24:31 -0500 Subject: [PATCH 2/2] Restore crash workaround for Chromium w/o WebRTC --- src/js/migrations.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/js/migrations.js b/src/js/migrations.js index fbd4d1f48a..adc00fc837 100644 --- a/src/js/migrations.js +++ b/src/js/migrations.js @@ -259,6 +259,32 @@ exports.Migrations= { return; } + function checkWebRtcBrowserSupport() { + let available = true; + let connection = null; + + try { + let RTCPeerConnection = ( + window.RTCPeerConnection || window.webkitRTCPeerConnection + ); + if (RTCPeerConnection) { + connection = new RTCPeerConnection(null); + } + } catch (ex) { + available = false; + } + + if (connection !== null && connection.close) { + connection.close(); + } + + return available; + } + + if (!checkWebRtcBrowserSupport()) { + return; + } + console.log("Unsetting webRTCIPHandlingPolicy ..."); chrome.privacy.network.webRTCIPHandlingPolicy.get({}, function (res) { if (res.levelOfControl == 'controlled_by_this_extension') {