Forbid node adoption across the chrome/content boundary
Categories
(Core :: XPConnect, enhancement, P2)
Tracking
()
People
(Reporter: bzbarsky, Assigned: sefeng)
References
Details
(Keywords: sec-want, Whiteboard: [post-critsmash-triage], devrel-note, webext? [adv-main71-])
Attachments
(3 files)
1.18 KB,
patch
|
Details | Diff | Splinter Review | |
47 bytes,
text/x-phabricator-request
|
abillings
:
sec-approval+
|
Details | Review |
810 bytes,
application/x-zip-compressed
|
Details |
Reporter | ||
Comment 1•6 years ago
|
||
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Comment 3•6 years ago
|
||
Updated•6 years ago
|
Comment 4•6 years ago
|
||
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Comment 7•6 years ago
|
||
Reporter | ||
Comment 8•6 years ago
|
||
Reporter | ||
Updated•6 years ago
|
Comment 9•6 years ago
|
||
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Updated•6 years ago
|
Comment 10•6 years ago
|
||
Comment 11•6 years ago
|
||
Has anything changed here given the same compartment realms work that's recently landed?
Reporter | ||
Comment 12•6 years ago
|
||
Not really related, no.
Comment 13•5 years ago
|
||
So did bug 1516237 comment 5 affect this one.
(bug 1377999 isn't security bug, nor it is clear it will ever happen)
Comment 14•5 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #13)
So did bug 1516237 comment 5 affect this one.
That did land. I haven't paged all the details back in, but at least at the time I was pretty sure that approach fixed the specific issue in comment 0.
I still think forbidding content/chrome adoption is an important defense-in-depth change.
Comment 15•5 years ago
|
||
Then the question is that how high priority this bug should be?
Comment 16•5 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #15)
Then the question is that how high priority this bug should be?
It seems like it should be a simple enough change with high enough pay-off for it to be relatively high priority.
Comment 17•5 years ago
|
||
(In reply to Kris Maglione [:kmag] from comment #16)
(In reply to Olli Pettay [:smaug] from comment #15)
Then the question is that how high priority this bug should be?
It seems like it should be a simple enough change with high enough pay-off for it to be relatively high priority.
Comment 18•5 years ago
|
||
(priority is still unclear. There isn't known concrete security issue here, so this is more like ensuring we won't have security issues)
Comment 19•5 years ago
|
||
One potential known security issue is that we sanitize any markup that we put through a fragment parser in chrome documents, so the only way to inject unsanitized markup into chrome documents is to parse it in a content document and then adopt it into a chrome document. I think it's only a matter of time before someone starts doing that, if they aren't already.
Assignee | ||
Comment 20•5 years ago
|
||
I am working on disabling cross docGroup adoption in bug 1377999
Assignee | ||
Comment 21•5 years ago
|
||
Just as what kmag said, we do a lot of fragment parsing and adopt the created fragment into the chrome document, and the created fragments have a different docGroup than the chrome document because the principles are different. See here. Once we start to unsupport cross docGroup adoption, one of the ways to fix it is using importNode
to clone the node into the chrome document, and then do the adoption.
However, smaug raised a concern that if we start to prevent adopting cross-docgroups, perhaps worth to use system principal? I think bz also had some concerns about whether the DOMParser doc should in fact be in a separate docgroup from the document that created it. I'd like to know bz and smaug's thoughts here and see if we can agree on something.
Comment 22•5 years ago
|
||
Using importNode is memory heavy, so I'd rather see a way to not use that. But then, if one parses some string coming from a web page, that shouldn't ever use system principal/docGroup by default. (though, importNode can hide real origin of the dom fragment.)
Could we perhaps add some
[NewObject, ChromeOnly, Throws]
Document parseFromSafeString(DOMString str, SupportedType type);
to DOMParser and that would use system principal.
It should be relatively clear to the caller that it is up to it to ensure the string is safe to parse.
Reporter | ||
Comment 23•5 years ago
|
||
The proposal in comment 22 seems reasonable to me.
If we take that approach, we could conceivably also:
-
Have
parseFromSafeString
return aDocumentFragment
and create the nodes in the caller's document to start with. Probably not that big a deal if the caller can adopt. -
Have
importNode
throw when importing from non-system into system, and fix existing callers as needed.
Updated•5 years ago
|
Assignee | ||
Comment 24•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 25•5 years ago
|
||
Comment on attachment 9090762 [details]
Bug 1467970 - Unsupport cross docGroup adoption r=smaug
Security Approval Request
- How easily could an exploit be constructed based on the patch?: Very hard. It's more like an enhancement to a potential security issue that only exposed internally.
- Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: No
- Which older supported branches are affected by this flaw?: Not sure, maybe all branches? But again, these are no real security issue here.
- If not all supported branches, which bug introduced the flaw?: N/A
- Do you have backports for the affected branches?: No
- If not, how different, hard to create, and risky will they be?: Since there is no real security issue, it will be no different and not risky.
- How likely is this patch to cause regressions; how much testing does it need?: There should be no regressions. I don't think it requires any extra testing, as long as it passes all our test cases, it should be fine.
Comment 26•5 years ago
|
||
Comment on attachment 9090762 [details]
Bug 1467970 - Unsupport cross docGroup adoption r=smaug
sec-approval+ for mozilla-central
Comment 27•5 years ago
|
||
Comment 28•5 years ago
|
||
Updated•5 years ago
|
Comment 29•5 years ago
|
||
I was chatting with bz about this on IRC and he was leaning towards not trying to backport this fix, but he suggested I check with y'all about that. Do think we should let this ride the trains?
Comment 30•5 years ago
|
||
If we didn't uncover any concrete security issues in the process of developing and landing this, then I would treat this more as a defense-in-depth improvement, and not consider it critical for uplifting. So if we think the task of doing so is going to require non-trivial engineer time, I'd say we should skip it.
Comment 31•5 years ago
|
||
It looks like the patch mostly grafts as-is to ESR68. I'm wondering if maybe we should give this a cycle to bake and revisit when 71 is on Beta in mid-November?
Comment 32•5 years ago
|
||
The only real concern I have about not uplifting is that the patch hints at one of the last remaining avenues for chrome-level XSS that we know about. That said, if we're confident that none of the ancillary code we had to change to get this landed is likely to be exploitable, we should probably be OK.
Comment 33•5 years ago
|
||
This is not a security bug as such, and didn't see any obvious concrete security issues, so riding the trains should be fine.
Updated•5 years ago
|
Comment 34•5 years ago
|
||
Given the last few comments, I'm going to downgrade this to sec-want.
Reporter | ||
Comment 35•5 years ago
|
||
Given the various regressions filed here so far, have we done a try run where we MOZ_CRASH in the cases when this throws and see whether there are any resulting failures?
Assignee | ||
Comment 36•5 years ago
|
||
I did run dozens of try pushes to make sure the patch looks good in general for all test cases and all platforms. Speaking of MOZ_CRASH, I did used it a few times, but it looks like I didn't do it sufficiently. What I am going to do is I'll look for the filed regressions and I'll also do a try run with MOZ_CRASH in the case.
Assignee | ||
Comment 37•5 years ago
|
||
Looks like we didn't catch these regressions during try pushes because the corresponding test cases were missing.
Reporter | ||
Comment 38•5 years ago
|
||
Yes, I'm not saying we should have caught those regressions: if there's no test coverage, then there is no test coverage. If you did try pushes with MOZ_CRASH, no more action needed here...
Updated•5 years ago
|
Comment 39•5 years ago
|
||
It seems like this bug started with a concern about adopting DOM nodes from chrome into a content document, or vice versa, but the patch in the end prevents any adoptions across docGroups, which seems to impact web extensions (bug 1585588, and bug 1576508 comment 25).
Given that we already discovered a few regressions in our own code in the couple of weeks since this landed, I'm worried this might be a common pattern in 3rd party extensions, and that it might break a lot of them when this hits release.
I understand this is generally not a pattern to be encouraged, but would it be possible to temporary allow cross-docGroup adoption when both sides are content (which I think might currently only be possible with extensions, though I'm at the edges of my understanding here)?
Preferably, we would be able to announce this change on the addons blog, and only put it into effect a few releases later.
Boris and Sean (and others), what do you think?
Comment 40•5 years ago
|
||
Hi Philipp, we will probably need some comms about this issue, either in the next regular blog post (if my proposal is accepted), or something out of band otherwise.
Assignee | ||
Comment 41•5 years ago
•
|
||
TBH, I am not sure how/whether it will impact web extensions.
My understanding was node adoption which cross the docGroup boundary was only exposed to chrome document, so web extensions itself shouldn't have this privilege anyway, but I'd like to hear from Boris and Olli.
Reporter | ||
Comment 42•5 years ago
|
||
Looking at bug 1585588, it looks like the code there does new DOMParser
in a web extension content script. What docgroup does that DOMParser get? Does it get the same docgroup as the documents that content script can touch (and are all those in the same docgroup)?
Updated•5 years ago
|
Updated•5 years ago
|
Comment 43•5 years ago
|
||
This is a reduced STR extension, unzip and load it as a temporary addon from about:debugging, or zipped from about:addons after you set the pref xpinstall.signatures.required
to false (in a Nightly/local build).
(It seems bug 1576508 comment 25 is a different STR that doesn't use adoptNode
, but I'm yet to figure out exactly what that extension is doing and reduce it to a usable STR)
(In reply to Sean Feng [:sefeng] from comment #41)
TBH, I am not sure how/whether it will impact web extensions.
My understanding was node adoption which cross the docGroup boundary was only exposed to chrome document, so web extensions itself shouldn't have this privilege anyway, but I'd like to hear from Boris and Olli.
It definitely impacts extensions (see bug 1585588, and bug 1576508 comment 25), because a content script on example.com can (could) insert an iframe from a moz-extension:// url, and adopt nodes between them, even though they seem to be in different docGroups.
Comment 44•5 years ago
|
||
(In reply to :Tomislav Jovanovic :zombie from comment #43)
This is a reduced STR extension, unzip and load it as a temporary addon from about:debugging, or zipped from about:addons after you set the pref
xpinstall.signatures.required
to false (in a Nightly/local build).
And then open http://example.com
Comment 45•5 years ago
|
||
Sean, above are STR and details you asked for in bug 1585588 comment 17.
Comment 46•5 years ago
|
||
Even without a DOMParser, it's possible (until Fission) for a content script to access nodes from both web content and extension docGroups at the same time, and for tabs (unfortunately) to access nodes from background pages, popups, and sidebars, which are in completely different tabGroups.
Comment 47•5 years ago
|
||
Sure, possible, but we don't want that. That is what this whole bug is about.
Temporarily we could limit the change to chrome/non-chrome boundary, even though that would prevent bug 1377999 to land,
and would expose the extensions to possible security issues.
Comment 48•5 years ago
|
||
Agreed, I don't want us to loosen the security restrictions for these cases.
Reporter | ||
Comment 49•5 years ago
|
||
Even without a DOMParser, it's possible (until Fission)
It seems like we should disable things that will stop working with Fission, generally speaking, even if we don't have Fission enabled yet.... Presumably this stuff works in Chrome somehow, with their site isolation bits, so I'm a little surprised we're exposing different semantics from them.
Reporter | ||
Comment 50•5 years ago
|
||
Also, we might be best served here in filing a new bug to track the extension impact of this change, not least so we can track disabling this change temporarily for 71, if needed, until we get things sorted out...
Assignee | ||
Comment 51•5 years ago
|
||
Thanks zombie.
Shall we just back the patch out to make it not happen for the next release?
I could also come up a patch to limit the change to chrome/non-chrome boundary, or maybe a pref to disable it temporarily?
Comment 52•5 years ago
|
||
(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #49)
Even without a DOMParser, it's possible (until Fission)
It seems like we should disable things that will stop working with Fission, generally speaking, even if we don't have Fission enabled yet.... Presumably this stuff works in Chrome somehow, with their site isolation bits, so I'm a little surprised we're exposing different semantics from them.
The DOMParser stuff and the communication between tab pages and background pages/popups/sidebars do. The direct interaction between content scripts and extension frames does not. After Fission, only the last will stop working in Firefox. We're going to need to find a way to deal with the DocGroup/BrowsingContextGroup mismatch in the other cases sooner or later, since they break other invariant as well.
Updated•5 years ago
|
Comment 53•5 years ago
|
||
Thanks all, it seems we have a consensus that we should try to keep the security restrictions across content/chrome docGroups, and if we can, temporarily disable them for the content/content case (currently only possible with Web Extensions), and try to uplift that to Beta 71.
Filed bug 1590526 to track that work.
This will give us enough time to properly communicate the coming restrictions, with the intent of putting them into effect with Firefox 73 or 74.
Updated•5 years ago
|
Reporter | ||
Updated•5 years ago
|
Assignee | ||
Comment 54•5 years ago
|
||
zombie, do you have an idea about how we are going to communicate about the cross docGroup adoption changes to the addon community if we want to put them into effect? Like in how many releases? Whether this is acceptable or not from the addon team's point of view?
I am asking because bug 1377999 is ready to land, and if we want to keep supporting cross docGroup adoption, we need to make some changes into the patch, and we'd rather to not do that.
Comment 55•5 years ago
|
||
We considered explaining docGroups to extension developers was somewhat complicated, so we thought it would be better to do it together with the Fission intro/explainer. Once we're ready to invite people to try Fission on Nightly by flipping the pref and test their extensions, it should be easier to explain that content scripts won't be able to directly access documents in cross-origin (out of process) iframes, and deprecate cross-docGroup adoption (a subset) at the same time.
The plan was for that to already happen during March, but Fission progress is not at that point yet as a whole, and specifically we don't have OOPIF content scripts working yet. Not sure that answers your question, or how it aligns with your plans.
Comment 56•4 years ago
|
||
Removing employee no longer with company from CC list of private bugs.
Updated•4 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Description
•