1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-11-01 02:48:44 +01:00

"Protect" data URL pages by blocking outgoing requests

Fixes #208
This commit is contained in:
kkapsner 2018-07-16 00:14:44 +02:00
parent 8ca23e37e1
commit 47a9519ceb
8 changed files with 95 additions and 3 deletions

View File

@ -699,6 +699,15 @@
"description": "" "description": ""
}, },
"blockRequestsFromDataURL_title": {
"message": "Anfragen von Data-URL Seiten blockieren",
"description": ""
},
"blockRequestsFromDataURL_description": {
"message": "Data-URL Seiten können nicht gegen Fingerprinting geschützt werden (siehe https://bugzilla.mozilla.org/show_bug.cgi?id=1475831). Indem Anfragen von Data-URL Seiten blockiert werden kann verhindert werden, dass der echte Fingerabdruck zu irgendeinem Server gelangt.",
"description": ""
},
"showReleaseNotes_title": { "showReleaseNotes_title": {
"message": "Versionsinformationen", "message": "Versionsinformationen",
"description": "" "description": ""

View File

@ -699,6 +699,15 @@
"description": "" "description": ""
}, },
"blockRequestsFromDataURL_title": {
"message": "Block requests from data URL pages",
"description": ""
},
"blockRequestsFromDataURL_description": {
"message": "Data URL pages cannot be protected agains fingerprinting (see https://bugzilla.mozilla.org/show_bug.cgi?id=1475831). Blocking requests from them prevents the real fingerprint to reach any server.",
"description": ""
},
"showReleaseNotes_title": { "showReleaseNotes_title": {
"message": "Release notes", "message": "Release notes",
"description": "" "description": ""

50
lib/dataUrls.js Normal file
View File

@ -0,0 +1,50 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){
"use strict";
var scope;
if ((typeof exports) !== "undefined"){
scope = exports;
}
else {
window.scope.dataUrls = {};
scope = window.scope.dataUrls;
}
const logging = require("./logging");
const settings = require("./settings");
const dataUrlFrames = new Set();
scope.init = function(){
browser.webRequest.onBeforeRequest.addListener(
function(details){
if (
details.url.startsWith("data:text")
){
dataUrlFrames.add(details.frameId);
logging.message("Detected data URL", details);
}
else if (
settings.blockRequestsFromDataURL &&
dataUrlFrames.has(details.frameId)
){
logging.warning("Blocking request from data-URL frame.", details);
if (
settings.get("showNotifications")
){
browser.pageAction.show(details.tabId);
}
return {cancel: true};
}
},
{
urls: ["<all_urls>"]
},
["blocking"]
);
};
}());

View File

@ -141,6 +141,9 @@
} }
}); });
message("Initialize data-URL workaround.");
require("./dataUrls").init();
browser.runtime.onInstalled.addListener(function(details){ browser.runtime.onInstalled.addListener(function(details){
function openOptions(reason){ function openOptions(reason){
if ( if (

View File

@ -200,6 +200,10 @@
return Math.floor(Math.random() * 30).toString(10); return Math.floor(Math.random() * 30).toString(10);
} }
}, },
{
name: "blockRequestsFromDataURL",
defaultValue: true
},
{ {
name: "displayAdvancedSettings", name: "displayAdvancedSettings",
defaultValue: false defaultValue: false

View File

@ -2,7 +2,7 @@
{ {
"name": "CanvasBlocker", "name": "CanvasBlocker",
"description": "__MSG_addon_description__", "description": "__MSG_addon_description__",
"version": "0.4.6alpha", "version": "0.5.0",
"icons": { "icons": {
"48": "icons/icon.svg", "48": "icons/icon.svg",
"96": "icons/icon.svg" "96": "icons/icon.svg"
@ -15,6 +15,7 @@
"lib/logging.js", "lib/logging.js",
"lib/lists.js", "lib/lists.js",
"lib/persistentRndStorage.js", "lib/persistentRndStorage.js",
"lib/dataUrls.js",
"lib/main.js" "lib/main.js"
] ]
}, },
@ -65,7 +66,9 @@
"<all_urls>", "<all_urls>",
"storage", "storage",
"tabs", "tabs",
"activeTab" "activeTab",
"webRequest",
"webRequestBlocking"
], ],
"applications": { "applications": {

View File

@ -379,6 +379,12 @@
] ]
}, },
"misc", "misc",
{
"name": "blockRequestsFromDataURL",
"displayDependencies": {
"displayAdvancedSettings": [true]
}
},
{ {
"name": "showReleaseNotes" "name": "showReleaseNotes"
}, },

View File

@ -1,4 +1,4 @@
Version 0.4.6: Version 0.5.0:
changes: changes:
- Changes in the random supply API - Changes in the random supply API
- Added grouping to API white list - Added grouping to API white list
@ -10,6 +10,14 @@ Version 0.4.6:
fixes: fixes:
- make function replacements not detectable - make function replacements not detectable
- "protect" data URL pages by blocking all requests from them
removed fixes:
- display of about:blank broken in Waterfox
reason: it should help protect data URL pages in the future
known issues:
- if a data URL request is blocked the page action button appears but shown no content
Version 0.4.5c: Version 0.4.5c:
new features: new features: