summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorjahoti <jahoti@tilde.team>2021-07-17 00:00:00 +0000
committerjahoti <jahoti@tilde.team>2021-07-17 00:00:00 +0000
commit8b823e1a6f29e52effc086d02dfe2e2812b2e187 (patch)
treed86f7a69cb5faf00050aa774e3d2b675a41245ad /common
parent692577bbde5e8110855c022ec913324dfddce9ae (diff)
downloadbrowser-extension-8b823e1a6f29e52effc086d02dfe2e2812b2e187.tar.gz
browser-extension-8b823e1a6f29e52effc086d02dfe2e2812b2e187.zip
Revamp signatures and break header caching on FF
Signatures, instead of consisting of the secure salt followed by the unique value generated from the URL, are now the unique value generated from the policy value (which will follow them) succeeded by the URL. CSP headers are now _always_ cleared on FF, regardless of whether the page is whitelisted or not. This means whitelisting takes effect on page reload, rather than only when caching occurs. However, it obviously presents security issues; refinment will occur in a future commit.
Diffstat (limited to 'common')
-rw-r--r--common/misc.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/common/misc.js b/common/misc.js
index 825a117..036eb45 100644
--- a/common/misc.js
+++ b/common/misc.js
@@ -35,9 +35,9 @@ function gen_unique(url)
function get_secure_salt()
{
if (is_chrome)
- return browser.runtime.getManifest().key.substring(0, 36);
+ return browser.runtime.getManifest().key.substring(0, 50);
else
- return browser.runtime.getURL("dummy").substr(16, 36);
+ return browser.runtime.getURL("dummy");
}
/*
@@ -107,19 +107,19 @@ function is_privileged_url(url)
/* Extract any policy present in the URL */
function url_extract_policy(url)
{
+ var policy_string;
const targets = url_extract_target(url);
- const key = '#' + get_secure_salt();
- targets.sig = key + gen_unique(targets.base_url);
- if (targets.target && targets.target.startsWith(key)) {
- targets.signed = true;
- if (targets.target.startsWith(targets.sig))
- try {
- const policy_string = targets.target.substring(101);
- targets.policy = JSON.parse(decodeURIComponent(policy_string));
- } catch (e) {
- /* TODO what should happen here? */
- }
+ try {
+ policy_string = targets.target.substring(65);
+ targets.policy = JSON.parse(decodeURIComponent(policy_string));
+ } catch (e) {
+ /* TODO what should happen here? */
+ }
+
+ if (targets.policy) {
+ const sig = gen_unique(policy_string + targets.base_url);
+ targets.valid_sig = targets.target.substring(1, 65) === sig;
}
return targets;