5 ms·
> According to the research team, in most of the cases they analyzed, the Chrome extensions disabled CSP and other security headers “to introduce additional see
by xg15 5y ago
> According to the research team, in most of the cases they analyzed, the Chrome extensions disabled CSP and other security headers “to introduce additional seemingly benign functionalities on the visited webpage,” and didn’t look to be malicious in nature.
Yes, because Chrome's architecture forces extensions to do this, ironically in the name of security.
Normal extension code can access a page's DOM but it cannot interact with any scripts on the page.
If you want your extensions to interact with the page's JS, the only way is to play man-in-the-middle and inject your own JS as if it was loaded by the page.
- danShumway 5y ago> Yes, because Chrome's architecture forces extensions to do this, ironically in the name of security. To be fair, I think Firefox has this restriction too? I might be wrong, but I could have sworn I ran into some script-injection extensions that weren't working on some sites because of this problem. It's been a while since I checked, I eventually gave up on the extensions because I wanted to thin out my list and I wasn't comfortable with them overriding CORS headers -- so things may have changed, or maybe I misunderstood the situation even back then.
- rjzzleep 5y agoYeah, I keep having issues with CORS headers in Firefox and then it becomes really hard to pinpoint which extension caused what. I may be wrong but it didn't used to be like that. It's a sideeffect of the whole webextension concept no?
- danShumway 5y agoMaybe? I vaguely remember webextensions not needing to do this. But I can't say that with certainty, because it might be that most websites didn't enable CORS so I never noticed, or I could just have the timeline mixed up in my head. I don't think anything about webextensions requires this problem to exist. So if it is a problem with webextensions, it's a problem we've "chosen" to have. And browsers could fix this without drastically overhauling anything with extensions. But I can not stress enough how much out of my depth I am commenting on this, my full knowledge is basically a couple days worth of research a year or two ago and some interaction on a bug report.
- kevingadd 5y agoAny proper implementation of the cors eval/script constraints would block extension script injection, regardless of whether webextensions are used. You'd have to run code outside of the page context, which automatically poses issues since the page is probably in another process.
- bfrit 5y agoThe problem is that the extension can alter or fully remove the cors headers before it injects scripts, neutering even the best configuration.
- berdario 5y agoWhat are some use cases for interacting with other scripts, instead of interacting with the DOM? I suppose that if you want to disable some behavior in the website (to insert your own extension's before letting the website's own execute) you have to do that... But when would you want to do that?
- dessant 5y agoWhen you want to hook into page functionality and extend it. For example, extensions for YouTube will routinely access the JS objects of the page and listen to player events in order to introduce new features. This is only possible if you run your code in the context of the page.
- viraptor 5y agoYou can add new scripts to the page though. You don't have to interfere with the existing scripts / change them. That doesn't break CSP if you do it the right way.
- dessant 5y agoInteracting with the page as if your code would have been loaded by the page is only possible if you inject your code in the page context, typically using a script tag in Chrome, at which point you are governed by the CSP restrictions of the page. You either relax those restrictions in some way, or you can't run your code in the JS context of the page. It's possible to run code in a content script regardless of how restrictive the pages's CSP headers are, but you are running in an isolated environment that can only access the page DOM.
- vbezhenar 5y agoCan you provide an example of the website which makes it impossible to insert JS from extension? I'd like to tinker with it. I wrote a simple extension which inserted JS to youtube and it worked just fine. I thought youtube is secure enough?
- vbezhenar 5y agoWhat about Message passing (https://developer.chrome.com/docs/extensions/mv3/messaging/ https://developer.chrome.com/docs/extensions/mv3/messaging/)?