Closed Bug 938640 Opened 11 years ago Closed 11 years ago

It's possible to call some methods on a cross-origin window

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29
Tracking Status
firefox25 --- unaffected
firefox26 --- unaffected
firefox27 + fixed
firefox28 + fixed
firefox29 --- fixed
firefox-esr17 --- unaffected
firefox-esr24 --- unaffected
b2g18 --- unaffected
b2g-v1.1hd --- unaffected
b2g-v1.2 --- unaffected
b2g-v1.3 --- fixed
b2g-v1.3T --- fixed
b2g-v1.4 --- fixed

People

(Reporter: moz_bug_r_a4, Assigned: peterv)

References

Details

(Keywords: csectype-disclosure, regression, sec-high, Whiteboard: [qa-])

Attachments

(6 files)

It seems that this is a regression from bug 918345. It's possible to call some methods on a cross-origin window. For example: - it's possible to get Selection from a target page. - it's possible to open a popup on a target page. - it's possible to spoof document.referrer.
Attached file testcase 1 - getSelection (deleted) —
Attached file testcase 2 - fake password popup (deleted) —
Attached file show document.referrer (deleted) —
This is used to show document.referrer.
Attached file testcase 3 - spoof referrer (deleted) —
Investigating.
Blocks: 918345
Looks like we're getting our inners/outers wrong. Does the quickstubs unwrapping code do an UncheckedUnwrap somewhere?
Assigning to bz per comment 5, adjust as desired.
Assignee: nobody → bzbarsky
Keywords: regression
Ping me if you need anything bz.
Component: Security → DOM
So getSelection started working because instead of computing this (which outerizes), we actually use the right inner as this for bareword method calls now. That means that getSelection lands in nsGlobalWindow code, which blindly forwards to outer. We should really fix this in some principled way... Maybe by doing both computethis (which will give us the outer) and getting the global of the function and then throwing a security exception if they're not same-origin? Or maybe forwarding to outer should only work from the current inner, at least for DOM-accessible stuff? It's weird to do getSelection on some inner and get the selection for whatever the current iiner is. Testcase 2 is the same issue but with prompt(). Testcase 3 I'm still looking into, since setTimeout _does_ try to check whether it has the right inner, last I checked.
Ah, Testcase 3 is just setting a timeout on a non-current inner, which then does a location set. And location sets are allowed cross-origin and end up using a referrer based on the JSContext or something, which is now associated with the new inner. So that part is basically bug 936129, I think.
But the upshot is that we either need to change bindings to do something different here or we need to audit everything that forwards to outer.
Flags: needinfo?(bobbyholley+bmo)
Yeah, I think that we should rewrite FORWARD_TO_OUTER to bail if the inner is not the current inner. The current setup is just asking for trouble. Any internal consumers that this change breaks can just be rewritten to explicitly grab the outer.
Flags: needinfo?(bobbyholley+bmo)
Peter is looking at this.
Assignee: bzbarsky → peterv
I've started by changing just FORWARD_TO_OUTER_OR_THROW (and that's green on try). Am now looking at all the WebIDL methods/getters/setters and found a couple that use FORWARD_TO_OUTER that I'll change next. That should get us back to where we were. I'll see if it's doable to audit all the others.
Status: NEW → ASSIGNED
Blocks: 940085
Variants of this in bug 940085 affect 24 to 28, so I'm just going to mark those as affected here, where the patch will likely live (bz says the same fix should work).
Attached patch Move GetTopImpl v1 (deleted) — Splinter Review
This just moves code around, preparation for next patch.
Attachment #8346631 - Flags: review?(bzbarsky)
Attached patch v1 (deleted) — Splinter Review
Green on try. The assertion fix is a result from removing unused code in GetPrivateRoot. I'm still working on automating the testcases, almost done.
Attachment #8346632 - Flags: review?(bzbarsky)
Comment on attachment 8346631 [details] [diff] [review] Move GetTopImpl v1 r=me
Attachment #8346631 - Flags: review?(bzbarsky) → review+
Attachment #8346632 - Flags: review?(bzbarsky) → review+
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Comment on attachment 8346632 [details] [diff] [review] v1 [Approval Request Comment] Bug caused by (feature/regressing bug #): User impact if declined: Testing completed (on m-c, etc.): Risk to taking this patch (and alternatives if risky): String or IDL/UUID changes made by this patch: [Approval Request Comment] Bug caused by (feature/regressing bug #): bug 918345 User impact if declined: security bug, this allows code from a different origin to access web page data Testing completed (on m-c, etc.): landed on m-c, still working on the automated testcase, but we should probably land that separately anyway as it shows the problem pretty clearly Risk to taking this patch (and alternatives if risky): this might break some code that relies on calling APIs on non-current inner windows, but that should be rare. I went through a lot of callers and checked that they either worked or I fixed the API involved. I'm fairly confident we won't see breakage. String or IDL/UUID changes made by this patch: none
Attachment #8346632 - Flags: approval-mozilla-beta?
Attachment #8346632 - Flags: approval-mozilla-aurora?
I don't think this affects anything before 27 (where bug 918345 landed). Let me know if I'm missing something.
It's affecting earlier releases due to bug 936056; see bug 940085. But I think the right fix there is to backport the much simpler patch for bug 936056.
This should have gotten sec-approval before landing (https://wiki.mozilla.org/Security/Bug_Approval_Process).
(In reply to Boris Zbarsky [:bz] from comment #24) > It's affecting earlier releases due to bug 936056; see bug 940085. > > But I think the right fix there is to backport the much simpler patch for > bug 936056. Yeah, I've sort of considered the problems with earlier branches as a result of bug 936056, not this bug. (In reply to :Gavin Sharp (email gavin@gavinsharp.com) from comment #25) > This should have gotten sec-approval before landing > (https://wiki.mozilla.org/Security/Bug_Approval_Process). Hrmpf, yes, sorry about that. Old habits die hard.
Comment on attachment 8346632 [details] [diff] [review] v1 well, it's in now so let's uplift.
Attachment #8346632 - Flags: approval-mozilla-beta?
Attachment #8346632 - Flags: approval-mozilla-beta+
Attachment #8346632 - Flags: approval-mozilla-aurora?
Attachment #8346632 - Flags: approval-mozilla-aurora+
Flags: in-testsuite+
Whiteboard: [qa-]
Depends on: 951245
Group: core-security
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: