Skip to content

Commit 29b2f7b

Browse files
committed
Fix incorrect uses of default policy
when a container-specific policy from the contextStore should be used instead
1 parent 4105f79 commit 29b2f7b

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/bg/RequestGuard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@
390390

391391
const wantsTemp = forcedTemp || checked.includes("temp");
392392
if (!contextMatch) {
393-
const isDefault = perms === ns.policy.DEFAULT;
393+
const isDefault = perms === policy.DEFAULT;
394394
perms = perms.clone();
395395
if (isDefault) perms.temp = wantsTemp;
396396
policy.set(key, perms);

src/bg/TabGuard.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ var TabGuard = (() => {
184184

185185
// we suspect tabs which 1) have not been removed/discarded, 2) are restricted by policy, 3) can run JavaScript
186186
let suspiciousTabs = [...ties].map(TabCache.get).filter(
187-
tab => tab && !tab.discarded && ns.isEnforced(tab.id) &&
188-
(!(tab._isExplicitOrigin = tab._isExplicitOrigin || /^(?:https?|ftps?|file):/.test(tab.url)) || ns.policy.can(tab.url, "script"))
187+
tab => tab && !tab.discarded && ns.isEnforced(tab.id) && (
188+
!(tab._isExplicitOrigin = tab._isExplicitOrigin || /^(?:https?|ftps?|file):/.test(tab.url)) ||
189+
ns.getPolicy(tab.cookieStoreId).can(tab.url, "script")
190+
)
189191
);
190192

191193
return suspiciousTabs.length > 0 && (async () => {
@@ -222,7 +224,7 @@ var TabGuard = (() => {
222224
}
223225
if (tab.url !== "about:blank") {
224226
debug(`Real origin for ${tab._externalUrl} (tab ${tab.id}) is ${tab.url}.`);
225-
if (!ns.policy.can(tab.url, "script")) return;
227+
if (!ns.getPolicy(tab.cookieStoreId).can(tab.url, "script")) return;
226228
}
227229
}
228230
if (!tab._contentType) {

src/bg/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@
339339
return tab?.url || documentUrl || url;
340340
},
341341
requestCan(request, capability) {
342-
return !this.isEnforced(request.tabId) || this.policy.can(request.url, capability, this.policyContext(request));
342+
return (
343+
!this.isEnforced(request.tabId) ||
344+
ns.getPolicy(request.cookieStoreId).can(request.url, capability, this.policyContext(request))
345+
);
343346
},
344347

345348
getPolicy(cookieStoreId){

src/ui/ui.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ var UI = (() => {
11391139
}
11401140

11411141
_customOrAuto(row) {
1142-
const { policy } = UI;
1142+
const policy = this.policy;
11431143
const { perms, contextMatch, siteMatch } = row;
11441144
const isAuto = policy.autoAllowTop && perms.temp &&
11451145
contextMatch == siteMatch &&
@@ -1363,7 +1363,7 @@ var UI = (() => {
13631363
w.title = title;
13641364
w.textContent &&= label;
13651365
}
1366-
row._customPerms = perms = UI.policy.cascade(this.policy.DEFAULT, this.mainUrl, {permissions: true});
1366+
row._customPerms = perms = this.policy.cascade(this.policy.DEFAULT, this.mainUrl, {permissions: true});
13671367
}
13681368
preset.classList.toggle("canScript", perms.capabilities.has("script"));
13691369
}

0 commit comments

Comments
 (0)