"ASSERTION: should have a JS object by this point" with setUserData, GC

RESOLVED FIXED

Status

()

Core
XPConnect
RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: Jesse Ruderman, Assigned: mrbkap)

Tracking

(Blocks: 2 bugs, {assertion, testcase})

Trunk
x86
Mac OS X
assertion, testcase
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(blocking2.0 -)

Details

(Whiteboard: [sg:nse] fixed-in-tracemonkey)

Attachments

(3 attachments)

(Reporter)

Description

7 years ago
Created attachment 516190 [details]
testcase (requires extension for GC)

1. Install 'DOM Fuzz Lite' from
    https://www.squarefree.com/extensions/domFuzzLite.xpi
2. Load the testcase.

###!!! ASSERTION: should have a JS object by this point: 'win->GetOuterWindowInternal()->IsCreatingInnerWindow()', file dom/base/nsDOMClassInfo.cpp, line 5022

###!!! ASSERTION: Non-global object has the wrong flags: '!(jsclazz->flags & JSCLASS_IS_GLOBAL)', file js/src/xpconnect/src/xpcwrappednative.cpp, line 1153

Security-sensitive because I'm scared of anything that involves GC. Or inner and outer windows.
(Reporter)

Comment 1

7 years ago
Created attachment 516191 [details]
stack traces
(Reporter)

Updated

7 years ago
blocking2.0: --- → ?

Comment 2

7 years ago
This doesn't look exploitable. Why blocking?

Comment 3

7 years ago
b- please renom if we see any indication that this is indeed exploitable
blocking2.0: ? → -
Given that we don't know of this being exploitable or anything, marking this sg:nse, and keeping it closed for now. Blake, can you have a look?
Assignee: nobody → mrbkap
Whiteboard: [sg:nse]
(Assignee)

Comment 5

7 years ago
Created attachment 517543 [details] [diff] [review]
Proposed fix

So, the problem here is that the variant holds a reference to the outer window proxy and a reference to the current inner window's C++ object. After the iframe navigates, we brain transplant the outer window, and the old inner window's JS object has no more references to it, so we collect it. Later, we attempt to wrap the inner window into JS and recreate its JS object (and hit the assertion). This patch fixes this by making us hold a reference to the non-brain-transplanted inner object, meaning we won't recreate the JS object. This means we'll hold the old inner window alive longer, but I'm OK with that.
Attachment #517543 - Flags: review?(jst)

Updated

7 years ago
Attachment #517543 - Flags: review?(jst) → review+
(Assignee)

Comment 6

7 years ago
http://hg.mozilla.org/tracemonkey/rev/41ea0740c97d
Whiteboard: [sg:nse] → [sg:nse] fixed-in-tracemonkey
Blake: we don't have brain transplants on the 1.9.x branches, but we do have inner and outer windows and we have seen the assertions in comment 0 (bug 637226). Do we need a variant of this fix on branches? Maybe not if it's truly unexploitable.
(Assignee)

Comment 8

7 years ago
No. On older branches, the variant ends up holding a strong reference to the outer window, not the inner and the jsval that it holds is also for the outer, so it won't be garbage collected. Because the value and the nsISupports match there is no bug.
Group: core-security
Blocks: 637226
(Assignee)

Comment 9

6 years ago
http://hg.mozilla.org/mozilla-central/rev/41ea0740c97d
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.