-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocking webRequest usecase - add, modify and remove CSP directives #169
Comments
Someone should probably make a meta issue that lists evidence that currently MV3 extensions actually reduce safety of the users or web sites because there's no other way to implement features. Another such case where total removing of the site's CSP would be required is to implement |
Would |
Since RE2 syntax for regex doesn't support lookahead and complex matching, regexSubstitution would work only for the cases that are relatively simple like the one reported in https://crbug.com/1254637. |
One use case we have had to modify CSPs using blocking web requests is to allow styles/stylesheets that support extension UI being added to the page |
Following the last meeting of the WECG, I am adding our use case to support this request. We are a large SaaS company with a product that is implemented using a browser extension that adds functionality on top of existing web applications. Examples for types of customizations that can be blocked by CSP:
When faced with a CSP restriction we have the following alternative solutions:
We believe the best solution is to have a dedicated CSP API for web extensions. This API should overcome CSP headers and CSP meta tags. Not having a solution to this problem might push some extension authors to remove the CSP headers completely using DNR (we will not do it, of course). So at the end of the day we believe that a solution to this problem would increase the overall security posture of the web extensions ecosystem. |
Could you be a bit more specific? Web-accessible extension URLs are supposedly exempt from the CSP restrictions. This is even one of the rare cases where a specification mentions extension interaction explicitly, at https://www.w3.org/TR/CSP3/#extensions:
The request here was originally about replacements for webRequest + CSP. Even if DNR were to get the capability to manipulate CSP, it wouldn't address the Note: webRequest+CSP modification is and has always been a big hack; One of the unresolved open issues is that extensions cannot cooperate with each other to define the desired behavior.
Thanks!
"Adding small javascript snippets" fits the description of a user script manager. Since the feature is optional, would an optional permission work? Alternatively, if the snippets are static, they can be embedded in the extension and be inserted with the regular scripting API. |
Probably not, because Chrome web store policies aggressively insist that an extension must have a single purpose, and being a userscript manager is not just an optional permission that any extension can use but a separate purpose in itself. |
Technically you are correct. But this is not the primary purpose of our extension so we would be reluctant to represent ourselves as such.
No. Optional permissions in general do not work well for us because of the way our product is being used. Our product integrates with the end user's flow of work, and usually they are not aware that a browser extension is involved. Therefore we cannot show a permission request popup.
I'm afraid that it is not static. Thanks for following up on this, @Rob--W. While "User Script API" may solve the script-src CSP problem for some extensions (not for us), as I mentioned in my previous comment, the problem is more broad (images, stylesheets, etc...) and requires a general CSP solution (either deidcated CSP API or using DNR) |
I went back and looked and we were whitelisting our own domain name where we had a stylesheet or a font file |
With the blocking webRequest API, it is possible to actively read and change the CSP directive.
However, with DNR, you can only set a complete header without knowing what the original value was. This leads to situations in which in a DNR environment, the complete CSP has to be removed as it can't be predirected what the CSP could be.
An example is a CSP which contains a nonce. Say the extension tries to modify the frame-ancestors directive. It would have to know the nonce value of the request. Without knowing it, the CSP has to be too unsafe to be acceptable under the DNR situationl.
The text was updated successfully, but these errors were encountered: