Skip to content

Commit 3b266e9

Browse files
committed
Remove sync fetching exception for network-served embedding documents (thanks Security Research Labs for report).
1 parent 6e7328a commit 3b266e9

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/bg/DNRPolicy.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020

2121
// depends on /nscl/service/NavCache.js
2222

23+
// This module is meant to replace the granular content blocking performed by RequestGuard.js
24+
// on Manifest V2/2.5 (based on Firefox's blocking async webRequest API)
25+
// with a declarativeNetRequest implementation on Manifest V3.
26+
// One IMPORTANT difference is that this implementation won't try to inject Content-Security-Policy
27+
// headers in documents for content blocking (the only one being injected is for reporting only):
28+
// in MV3 all the CSP heavy lifting is done by staticNS.js via nscl's DocumentCSP, so it's vital
29+
// that content-side the correct policy is always fetched timely (synchronously, if needed).
30+
2331
'use strict';
2432
{
2533
const DEFAULT_PRIORITY = 1;

src/content/staticNS.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@
121121
});
122122
const {readyState} = document;
123123
asyncFetch();
124+
// WARNING: be careful adding exceptions to sync fetching here, since on MV3 we never have
125+
// content-blocking CSP headers injected at the network level (DNRPolicy.js doesn't).
124126
if (this.policy || readyState == "complete" ||
125-
!this.syncFetchPolicy && this.embeddingDocument ||
126127
window.origin == "null" && window.location.href == "about:blank" && window.top == self
127128
) {
128129
// no point trying sync too in these cases

0 commit comments

Comments
 (0)