News for hackers. Stuff that matters.
Re:Chrome extensions are tampering with security headers by xg15 on Tuesday May 25, 2021 @09:50PM (#27285218)
> 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.

Re:Chrome extensions are tampering with security headers by danShumway on Tuesday May 25, 2021 @11:46PM (#27286034)
> 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.

Re:Chrome extensions are tampering with security headers by rjzzleep on Wednesday May 26, 2021 @12:00AM (#27286153)
Yeah, 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?

Re:Chrome extensions are tampering with security headers by danShumway on Wednesday May 26, 2021 @12:10AM (#27286222)
Maybe? 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.

Re:Chrome extensions are tampering with security headers by kevingadd on Wednesday May 26, 2021 @12:46AM (#27286472)
Any 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.
Re:Chrome extensions are tampering with security headers by bfrit on Wednesday May 26, 2021 @02:56AM (#27287259)
The problem is that the extension can alter or fully remove the cors headers before it injects scripts, neutering even the best configuration.
Re:Chrome extensions are tampering with security headers by berdario on Wednesday May 26, 2021 @01:33AM (#27286755)
What 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?

Re:Chrome extensions are tampering with security headers by dessant on Wednesday May 26, 2021 @02:03AM (#27286927)
When 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.
Re:Chrome extensions are tampering with security headers by viraptor on Wednesday May 26, 2021 @02:54AM (#27287247)
You 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.
Re:Chrome extensions are tampering with security headers by dessant on Wednesday May 26, 2021 @03:06AM (#27287312)
Interacting 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.

Re:Chrome extensions are tampering with security headers by vbezhenar on Wednesday May 26, 2021 @06:56AM (#27288836)
Can 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?
Re:Chrome extensions are tampering with security headers by qvq on Thursday May 27, 2021 @01:17AM (#27299647)
For a Chrome extension using manifest V2: you can inject "inline" scripts into the DOM and interact with a page's JS regardless of the CSP.

For a Chrome extension using manifest v3: you can inject script tags with a src pointing to a local JS file in the extension regardless of the CSP.

Modifying the CSP is not a requirement for a Chrome extension to interact with a page's JS. I don't know about other browsers though.

Re:Chrome extensions are tampering with security headers by Ajedi32 on Wednesday May 26, 2021 @11:20AM (#27291662)
YouTube does not (currently) send CSP headers from what I can see in the dev tools. Hacker News does, but it specifies "unsafe-inline" which negates most of the protection. Not aware of any sites with more locked down policies off the top of my head; it's not exactly an advertised feature of most sites.
Re:Chrome extensions are tampering with security headers by g3rv4 on Thursday May 27, 2021 @11:07PM (#27311312)
slack. I do so with my extension[0]. At one point they rewrote it and added CSP.

In order to inject my code before theirs, I had to come up with different approaches on FF and Chrome... and since it was starting to become a cat and mouse game, I just took the extension private.

After that, they didn't escalate their game. I'm thankful for that, so that I can keep enjoying it without spending lots of time figuring out how to mess with it.

[0] https://refined.chat

Re:Chrome extensions are tampering with security headers by rini17 on Wednesday May 26, 2021 @07:33PM (#27297488)
GitHub
Re:Chrome extensions are tampering with security headers by d110af5ccf on Wednesday May 26, 2021 @03:36AM (#27287513)
Adblockers often inject anti-anti-adblocking scripts. AFAIK, these are often drop-in replacements and so need to communicate with other scripts in the same way as the original.
Re:Chrome extensions are tampering with security headers by vbezhenar on Wednesday May 26, 2021 @04:44AM (#27287926)