From 640bd36b868cbb21ce64f1c7f4f17e6fa9fc947c Mon Sep 17 00:00:00 2001 From: kkapsner Date: Sun, 30 Jan 2022 10:59:41 +0100 Subject: [PATCH] Added SVG protection Fixes #589 and fixes #590 --- README.md | 1 + _locales/en/messages.json | 33 +++++++++++++++++++++++++++++++++ lib/askForPermission.js | 9 ++++++--- lib/modifiedAPI.js | 1 + lib/settingDefinitions.js | 10 ++++++++++ manifest.json | 1 + options/sanitationRules.js | 1 + options/settingsDisplay.js | 19 +++++++++++++++++++ options/whitelist.js | 6 ++++++ pageAction/pageAction.js | 1 + releaseNotes.txt | 2 +- versions/updates.json | 4 ++++ 12 files changed, 84 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eb8e841..31dd9da 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Protected "fingerprinting" APIs: * history * window (disabled by default) * DOMRect + * SVG * TextMetrics * navigator (disabled by default) * screen diff --git a/_locales/en/messages.json b/_locales/en/messages.json index a7b4f15..0ceb0b7 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -162,6 +162,10 @@ "message": "DOMRect API", "description": "" }, + "section_SVG-api": { + "message": "SVG API", + "description": "" + }, "section_TextMetrics-api": { "message": "TextMetrics API", "description": "" @@ -313,6 +317,18 @@ "message": "Do you want to allow DOMRect API readout?", "description": "" }, + "askForSVGPermission": { + "message": "Do you want to allow the SVG API?", + "description": "" + }, + "askForSVGInputPermission": { + "message": "Do you want to allow SVG API input?", + "description": "" + }, + "askForSVGReadoutPermission": { + "message": "Do you want to allow SVG API readout?", + "description": "" + }, "askForTextMetricsPermission": { "message": "Do you want to allow the TextMetrics API?", "description": "" @@ -751,6 +767,10 @@ "message": "Faked DOMRect readout on {url}", "description": "" }, + "fakedSVGReadout": { + "message": "Faked SVG readout on {url}", + "description": "" + }, "fakedTextMetricsReadout": { "message": "Faked TextMetrics readout on {url}", "description": "" @@ -1208,6 +1228,19 @@ "description": "" }, + "protectSVG_title": { + "message": "Protect SVG API", + "description": "" + }, + "protectSVG_description": { + "message": "This protects against fingerprinting using SVGs.", + "description": "" + }, + "protectSVG_urlSpecific": { + "message": "To exclude specific websites from this protection, click on the black arrow to open the menu, add the domain or URL by clicking on \"+\" and remove its checkmark.", + "description": "" + }, + "protectTextMetrics_title": { "message": "Protect TextMetrics API", "description": "" diff --git a/lib/askForPermission.js b/lib/askForPermission.js index fe7ae97..df3f658 100644 --- a/lib/askForPermission.js +++ b/lib/askForPermission.js @@ -88,7 +88,8 @@ audio: _("askForAudioPermission"), history: _("askForHistoryPermission"), window: _("askForWindowPermission"), - domRect: _("askForDOMRectPermission") + domRect: _("askForDOMRectPermission"), + svg: _("askForSVGPermission"), }, askStatus: { alreadyAsked: {}, @@ -103,7 +104,8 @@ audio: _("askForAudioInputPermission"), history: _("askForHistoryInputPermission"), window: _("askForWindowInputPermission"), - domRect: _("askForDOMRectInputPermission") + domRect: _("askForDOMRectInputPermission"), + svg: _("askForSVGInputPermission"), }, askStatus: { alreadyAsked: {}, @@ -118,7 +120,8 @@ audio: _("askForAudioReadoutPermission"), history: _("askForHistoryReadoutPermission"), window: _("askForWindowReadoutPermission"), - domRect: _("askForDOMRectReadoutPermission") + domRect: _("askForDOMRectReadoutPermission"), + svg: _("askForSVGReadoutPermission"), }, askStatus: { alreadyAsked: {}, diff --git a/lib/modifiedAPI.js b/lib/modifiedAPI.js index 9d38160..c426eda 100644 --- a/lib/modifiedAPI.js +++ b/lib/modifiedAPI.js @@ -39,6 +39,7 @@ appendModified(require("./modifiedHistoryAPI")); appendModified(require("./modifiedWindowAPI")); appendModified(require("./modifiedDOMRectAPI")); + appendModified(require("./modifiedSVGAPI")); appendModified(require("./modifiedTextMetricsAPI")); appendModified(require("./modifiedNavigatorAPI")); appendModified(require("./modifiedScreenAPI")); diff --git a/lib/settingDefinitions.js b/lib/settingDefinitions.js index 75fa115..7893094 100644 --- a/lib/settingDefinitions.js +++ b/lib/settingDefinitions.js @@ -124,6 +124,10 @@ "intersectionRect @ domRect", "boundingClientRect @ domRect", "rootBounds @ domRect", + {name: "SVG-API", level: 1}, + "getTotalLength @ svg", + "getComputedTextLength @ svg", + "getSubStringLength @ svg", {name: "TextMetrics-API", level: 1}, "width @ textMetrics", "actualBoundingBoxAscent @ textMetrics", @@ -280,6 +284,7 @@ "history", "window", "domRect", + "svg", "textMetrics", "navigator", "screen", @@ -356,6 +361,11 @@ name: "domRectIntegerFactor", defaultValue: 4 }, + { + name: "protectSVG", + defaultValue: true, + urlSpecific: true + }, { name: "protectTextMetrics", defaultValue: true, diff --git a/manifest.json b/manifest.json index cbadc91..43a8054 100644 --- a/manifest.json +++ b/manifest.json @@ -50,6 +50,7 @@ "lib/modifiedHistoryAPI.js", "lib/modifiedWindowAPI.js", "lib/modifiedDOMRectAPI.js", + "lib/modifiedSVGAPI.js", "lib/modifiedTextMetricsAPI.js", "lib/navigator.js", "lib/modifiedNavigatorAPI.js", diff --git a/options/sanitationRules.js b/options/sanitationRules.js index 69eec3d..c4d9391 100644 --- a/options/sanitationRules.js +++ b/options/sanitationRules.js @@ -83,6 +83,7 @@ {mainFlag: "protectAudio", section: "Audio-API"}, {mainFlag: "protectWindow", section: "Window-API"}, {mainFlag: "protectDOMRect", section: "DOMRect-API"}, + {mainFlag: "protectSVG", section: "SVG-API"}, {mainFlag: "protectTextMetrics", section: "TextMetrics-API"}, {mainFlag: "protectNavigator", section: "Navigator-API"}, {mainFlag: "protectScreen", section: "Screen-API"}, diff --git a/options/settingsDisplay.js b/options/settingsDisplay.js index 9c88912..7f43de0 100644 --- a/options/settingsDisplay.js +++ b/options/settingsDisplay.js @@ -627,6 +627,25 @@ }, ] }, + { + name: "SVG-API", + settings: [ + { + "name": "protectSVG" + }, + { + "name": "protectedAPIFeatures", + "replaceKeyPattern": / @ .+$/, + "displayedSection": "SVG-API", + "displayDependencies": [ + { + "protectSVG": [true], + "displayAdvancedSettings": [true] + } + ] + }, + ] + }, { name: "TextMetrics-API", settings: [ diff --git a/options/whitelist.js b/options/whitelist.js index e6da775..6bcffd5 100644 --- a/options/whitelist.js +++ b/options/whitelist.js @@ -61,6 +61,12 @@ whitelistValue: false, protectedValue: true }, + { + title: extension.getTranslation("section_SVG-api"), + name: "protectSVG", + whitelistValue: false, + protectedValue: true + }, { title: extension.getTranslation("section_navigator-api"), name: "protectNavigator", diff --git a/pageAction/pageAction.js b/pageAction/pageAction.js index 18bd555..4f7f1ab 100644 --- a/pageAction/pageAction.js +++ b/pageAction/pageAction.js @@ -75,6 +75,7 @@ canvas: {name: "protectedCanvasPart", value: "nothing"}, audio: {name: "protectAudio", value: false}, domRect: {name: "protectDOMRect", value: false}, + svg: {name: "protectSVG", value: false}, history: {name: "historyLengthThreshold", value: 10000}, navigator: {name: "protectNavigator", value: false}, windows: {name: "protectWindow", value: false}, diff --git a/releaseNotes.txt b/releaseNotes.txt index 3f35b1b..8b1a0c3 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -3,7 +3,7 @@ Version 1.8: - new features: - - + - added SVG protection fixes: - diff --git a/versions/updates.json b/versions/updates.json index 34d4a9f..0214fba 100644 --- a/versions/updates.json +++ b/versions/updates.json @@ -209,6 +209,10 @@ { "version": "1.8Alpha20211107", "update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.8Alpha20211107-an+fx.xpi" + }, + { + "version": "1.8Alpha20220130", + "update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.8Alpha20220130-an+fx.xpi" } ] }