4 ms·
I think Chrome's (and now Firefox') awkward extension sandboxing is partially to blame, though. When you add an extension page script, you get access to a page
by xg15 9y ago
I think Chrome's (and now Firefox') awkward extension sandboxing is partially to blame, though.
When you add an extension page script, you get access to a page's DOM, but you're completely isolated from the page's own JS: You get your own JS context and window object without any modifications the page may have done to it. That's usually reasonable as a page can mess with the built-in methods of its context, so if an extension were to rely on them, the risk of privilege escalation attacks would be really high.
Except sometimes an extension does want to interact with the page JS, (e.g. for accessing data the page only keeps in JS objects but not in the DOM.)
As far as I know, there is no safe way to do this in Chrome. The recommended (!) way is to inject a script element into the DOM and exchange data with the page script via some makeshift communication channel, e.g. postMessaging yourself. This will of course drop you right back into the hall-of-mirrors of potentially manipulated builtins that the page script isolation was trying to keep you out of. But apparently now it's ok if you have to deal with that by yourself.
From the looks of it, it seems Grammarly tried to open exactly that kind of communication channel and didn't correctly secure it.
- bzbarsky 9y ago> I think Chrome's (and now Firefox') Chrome and Firefox have _very_ different behaviors here. In Chrome, there is no way at all to get hold of the page's JS objects. In Firefox, the default behavior is that you don't interact with them, but you can explicitly ask for them and once you have them you can work with them. Depending on what you do with them, you may or may not be creating security bugs, of course. Critically, in Firefox you can have your separate clean builtins _and_ be interacting with actual page JS objects at the same time. There are arguments for and against both models, of course.
- AgentME 9y agoThere's no reason to send the grammarly auth token into the page's javascript context to begin with. The ajax connections can be done with the auth token in the extension's protected content script context.