Cuyler Stuwe
unread,Aug 13, 2021, 9:23:03 AM8/13/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions, narayanann...@gmail.com, Jack, Simeon Vincent, Chromium Extensions, Cuyler Stuwe
@Simeon - No, as long as DeclarativeNetRequest works as described in the documentation, he definitely will be able to modify the CSP.
In both MV2 and MV3, the only way to change a CSP is in-flight, by altering the CSP header. It's just that in MV3, since you can't parse this header, you have to be much more heavy-handed with it. MV2 would let you read the network request, so that you could parse the CSP header and replace it with a slightly-tweaked version that adds your own rule into it (while leaving it otherwise intact). In MV3, you can't parse it, so your only option for relaxing the CSP is nuking the CSP header entirely.
Kinda like how the MV3 requirement of restarting service workers over and over goes against the stated goal of "performance", this constraint in network processing ironically makes it more difficult for a trustworthy extension to be "secure". Noble intentions don't really matter in life; All that matters are the outcomes of your actions -- and many of the outcomes of MV3 are working against its stated intents.
@Jack - Look into totally nuking the CSP header with an MV3 extension using the
DeclarativeNetRequest API. If that doesn't work as expected, then check Twitter for a service worker, which you might need to unregister and prevent from re-registering
(I've done this with a content script). With the WebRequest API, at the very least, there have been problems where a service worker can consume and manipulate a network request such that a browser extension never gets to see that it ever even occurred. It's a headache; I wish browser extensions had first dibs on these kinds of things. Maybe DeclarativeNetRequest works like this, and if so, it would at least be one benefit of it.