User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:18.104.22.168) Gecko/20060426 Firefox/22.214.171.124
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:126.96.36.199) Gecko/20060426 Firefox/188.8.131.52
This suite loads a frameset that contains a frameset which in turn contains a frame, launches a popup that keeps a reference to one of its elements, submits the innermost frame (to the delay perl script) and then replaces the inner frameset two times. For an unknown reason the old frame remains accessible from the popup window in a zombie state, it is possible to load web pages into it (the firefox status bar reflects that the page and its media are being loaded although nothing else is visible).
Even more weird, when launching a popup dialog from that frame, previously launched popup windows get overwritten - including chrome windows (e.g. browser properties).
Sometimes the browser also crashes while doing this due to an attempt to dereference a function pointer on a freed object. Here this should just crash the browser; although it seems to be impossible to me right now there might be the chance of executing arbitrary code that way.
Steps to Reproduce:
1. Unzip the contained files onto some web server (there's a perl file that is required for creating a delay of 2 seconds).
2. Open index.html
3. Follow instructions
Browser crashes or loads a custom html page into a chrome window
Created attachment 222338 [details]
Test suite for this bug - install on a perl enabled web server
I've put the testsuite here, for easier testing:
(instead of perl I used php here)
I've password protected it: username: frame , password: frame
Talkback ID with current trunk build: TB18791374M
nsQueryInterfaceWithError::operator() nsCOMPtr<nsIWebNavigation>::nsCOMPtr<nsIWebNavigation> nsLocation::GetHref XPTC_InvokeByIndex XPCWrappedNative::CallMethod
I don't crash in Mozilla1.7, so this is a regression.
(In reply to comment #2)
That test suite does not always work (probably only when using good connection and/or sites are already cached). After hitting the URL do nothing for 10 seconds, if the popup window closes itself something went wrong and it didn't work, it might work if you try again.
I think it's time to fix this possibly dangerous bug, it is still present in Firefox 184.108.40.206
Created attachment 224707 [details]
A simple exploit based on this bug, this time faking a master password dialog
It works like the previous test case: put onto perl enabled web space (required for the delay script), start index.html, click the button and wait about 10 seconds...
Things are delayed for easier development but could be done faster of course.
Created attachment 225344 [details]
backtrace from debug build
This is a backtrace from my debug build. It crashes as soon as the popup window gets opened.
Program received signal SIGSEGV, Segmentation fault.
0x6f208660 in JS_GetOptions (cx=0x0) at c:/mozilla/mozilla/js/src/jsapi.c:1049
warning: Source file is more recent than executable.
---Type <return> to continue, or q <return> to quit---
1049 return cx->options;
#0 0x6f208660 in JS_GetOptions (cx=0x0)
#1 0x05127872 in GetScriptContextFromJSContext(JSContext*) (cx=0x0)
#2 0x04f8a94f in nsJSUtils::GetDynamicScriptContext(JSContext*) (
aContext=0x0) at c:/mozilla/mozilla/dom/src/base/nsJSUtils.cpp:216
#3 0x04d44003 in IsContextOnStack(nsIJSContextStack*, JSContext*) (
#4 0x04d442bc in nsCxPusher::Push(nsISupports*) (this=0x22a2d0,
This regressed between 2005-08-22 and 2005-08-23:
In 2005-08-22 the popup window closes like it is supposed to do (I think).
In 2005-08-23 not anymore and opening the options window causes a crash.
This is a bad bug, cc-ing some people who want/might be able to fix this bug.
It it's needed, I could try and minimise the testcase further.
That last stack looks a lot like bug 340602... The crash in operator() is something else entirely, however.
hmm... in a build with the patch for bug 340602 in it I don't seem to crash.... Martijn, I assume you're still crashing with such a build?
Yes, I still crash with a 2006-06-12 trunk build.
What happens when you open the Options/Preferences window while the popup window is open (let the popup window open a few seconds before you open the Options/Preferences window)?
I've seen it happening once (when it didn't crash) that it gets replaced by a window from the user (but still with chrome privileges).
(In reply to comment #10)
> What happens when you open the Options/Preferences window while the popup
> window is open (let the popup window open a few seconds before you open the
> Options/Preferences window)?
> I've seen it happening once (when it didn't crash) that it gets replaced by a
> window from the user (but still with chrome privileges).
This is what the first attachment is expected to do (works most of the time on my computer). Did you try the second test case (224707)? IMO it should work better and crash less often.
In Firefox 220.127.116.11 the pref dialog gets replaced by user code. The the window is still a ChromeWindow, but the code appears to have normal user privilege. But given the chrom window thing we can probably play __parent__ tricks to re-elevate privilege.
Martijn, in comment 10 are you saying on the trunk that window has chrome privs already? Why the difference
(In reply to comment #12)
> Martijn, in comment 10 are you saying on the trunk that window has chrome privs
> already? Why the difference
Sorry, I haven't tested that, I assumed that it had chrome privs.
It seems that the location object's mDocShell is not nulled out even though it
should be, and ends up being a dangling pointer. Is this a regression from Bug
I'm attaching two reduced testcases, which are iframe version and window.open()
version. On Windows XP, I can reproduce with both testcases, "Page Info"
window gets replaced by user code. On Linux, I can reproduce with iframe
version testcase, crashes.
When "Page Info" window got replaced by user code, the window no longer has
chrome privs (also on the trunk). And I cannot see a way to elevate privilege
using __parent__ tricks. Even when the location object points to the chrome
window (chrome://browser/content/pageInfo.xul), the location object itself is
not a privileged object, its __parent__ is the content window that has been
already closed. But, the user code can get the "Page Info" window's opener
that is a browser window. This could be abused somehow, but I don't have any
idea for now.
Created attachment 225845 [details]
reduced testcase using iframe
Created attachment 225846 [details]
reduced testcase using window.open()
However, by letting it crash in a controlled way, it's possible to inject custom code. I'll attach an example demonstrating that.
Created attachment 225924 [details]
Proof of concept for code injection
Works on windows only (should not rely on OS details) but requires Firefox 18.104.22.168: 2006050817 (probably German version only).
Yeah, this looks very likely to be a regression from bug 304882. How _is_ the docshell supposed to be nulled out now in mLocation, in general?
(In reply to comment #19)
1) A current document's mLocation.mDocShell is nulled out when a window is
2) If an old document's presentation has been cached in session history, its
mLocation.mDocShell is nulled out in WindowStateHolder dtor.
With the testcases in this bug, the old document's presentation is not cached
in session history. (when an old document is "about:blank" or is in subframe,
bfcache is not used.) Thus, WindowStateHolder for that document is not created,
and mLocation.mDocShell is left alone.
Created attachment 226355 [details] [diff] [review]
The trick here is that loading a new document in a window causes SetNewDocument to clear the outer window's mLocation. We can't invalidate the docshell then, since doing so would regress bug 304882 (so this is a regression from that bug). Therefore, the window will be unable to update the docshell on any lingering references to the location object, and if the docshell goes away, the location objects will happily continue using their deleted pointers.
Comment on attachment 226355 [details] [diff] [review]
Fix checked into trunk.
(In reply to comment #18)
> Works on windows only (should not rely on OS details) but requires Firefox
> 22.214.171.124: 2006050817 (probably German version only).
Exploit works just fine on an English version -- file created on my C:\ drive.
Comment on attachment 226355 [details] [diff] [review]
approved for 1.8.0 branch, a=dveditz for drivers
Fix checked into the 1.8.0 branch.
Checked into the 1.8 branch.
Good work. The bug seems to be gone in the nightly build in all test cases (including the web application which originally exhibited this bug).
v.fixed on 1.8.0 branch with Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US;
rv:126.96.36.199) Gecko/20060626 Firefox/188.8.131.52, no exploits from any testcases and per reporter's testing noted in comment #28.
Created attachment 230858 [details]
history test case
Fehler: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHistory.back]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/test/test.html :: c :: line 86" data: no]
This happens both in Firefox 184.108.40.206 and Firefox 220.127.116.11. Sorry for reporting it now as Firefox 18.104.22.168 has already been released but I didn't notice that before. Can someone please take a look and check what's going on and whether or not this is a real problem?
(In reply to comment #30)
> Can someone please take a look and check what's going on and whether or
> not this is a real problem?
This is the expected behavior (and what should be the behavior of the original testcase without the frames.location.href = 'about:blank').
I don't believe there's a potential exploit lurking here since we never have a case where the history object's only ref is from JS (the window holds onto it until it is closed), so the window can always null out the history object's docshell at the proper time.
So do some parts of this bug apply to aviary as well or is everything in here a regression not in aviary? At least, I can't get those testcases to work.