Closed Bug 328851 Opened 18 years ago Closed 18 years ago

[FIX]print preview killing browser's chrome

Categories

(Core :: Security, defect, P1)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha8

People

(Reporter: guninski, Assigned: bzbarsky)

References

(Depends on 1 open bug, )

Details

(Keywords: fixed1.8.1, verified1.8.0.4, Whiteboard: [sg:low])

Attachments

(3 files)

abuse of print preview and xbl kills browser's chrome and replace it with the print preview one.

don't know if it can be used more.

demo in the url.
related to Bug 328469 and Bug 325991.

in the description s/used/abused/
So there are two things going on here:

1)  Closing print preview reenables script, then recreates the galley presentation.  This runs the XBL constructor, etc.  So the JS executes before we've exited print preview.  If we do need to reenable script before we restore the galley presentation (seems likely, if XBL is involved), we should probably make sure to finish all UI operations first... or something.  Not sure.

2)  The access to Components.classes really breaks things.  I added some debug code to XPFE to see what's going on:

    var webBrowserPrint = this.getWebBrowserPrint();
    alert('got here');
    try {
      webBrowserPrint.exitPrintPreview(); 
    } catch (e) { alert(e); }
    alert('got here too');

I see one alert (the "got here") alert.  The other alerts do not happen.  No code in this function after this point executes.  So it feels to me like the JS engine thinks an exception got thrown.. but it's not catchable, etc.

I'm trying to come up with a better testcase for that right now.
Assignee: nobody → dveditz
Component: General → Security
Product: Firefox → Core
QA Contact: general → toolkit
Not quite a testcase, but:

data:text/html,<iframe src='javascript:window.location="javascript:Components.classes"; alert("aaa");'></iframe>

In this case I never see an error in the JS console.  We do get a false return in nsJSContext::EvaluateString, but when we look for a native call context to notify about the pending exception we don't find one.

Note that if I do s/window/parent/ above then I DO get the error reported, via js_ReportUncaughtException called from JS_EvaluateUCScriptForPrincipals.  I don't know why that's not happening correctly in the data: URI above, but I bet that if we figured it out we could fix this bug.  ;)
Depends on: 328897
So there are several things going on here.  First of all, we lose error reports from javascript: URIs.  It's not obvious how best to fix that; I've filed bug 328902 on it.

After that, the problem is that when we get an error in EvaluateString we set the "exception thrown" boolean on the current XPConnect context... but the current XPConnect context is the one for the chrome call into C++, so chrome gets broken.

The safe fix for this is to make sure that NotifyXPCIfExceptionPending() only messes with XPCCallContexts that correspond to the JSContext it gets passed, imo.
Depends on: 328902
This fixes the testcase for me.  JS does still run when we exit print preview; Georgi, would you mind filing a separate bug for us to sort out whether that should happen?
Attachment #213513 - Flags: superreview?(brendan)
Attachment #213513 - Flags: review?(jst)
Attachment #213513 - Flags: approval-branch-1.8.1?(jst)
Not sure what other branches we should also take this on...
Assignee: dveditz → bzbarsky
Priority: -- → P1
Summary: print preview killing browser's chrome → [FIX]print preview killing browser's chrome
Target Milestone: --- → mozilla1.9beta
Comment on attachment 213513 [details] [diff] [review]
Proposed safe fix

r=jst
Attachment #213513 - Flags: review?(jst) → review+
Comment on attachment 213513 [details] [diff] [review]
Proposed safe fix

This looks good, but it implies that we don't need to set the exception pending somewhere else.  That seems to be the right thing.  Just looking for a way to deduce that other than testing ;-).

/be
Attachment #213513 - Flags: superreview?(brendan) → superreview+
See bug 328902 -- I think the call to NotifyXPCIfExceptionPending() is just wrong in this case.  I could add a warning if cx != aCx if you'd like...
Fixed on trunk.  Still not sure how much we want this for branches...
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
No, no need for a warning if we understand what's going wrong and are tracking it already via bug 328902.

/be
Attached file xbl-v1
cloning the attachmets here to make the bug self contained
Attached file html-v1
cloning the attachments here to make the bug self contained
bz fixed the bug (or at least kludged it) on today's suite trunk.
chrome no longer killed.

got assertion:

###!!! ASSERTION: no document: 'doc', file nsXULElement.cpp, line 2205

will file a bug about the js execution later, investigating.
(In reply to comment #5)
> JS does still run when we exit print preview;

a reason for this may be because of redraw - print preview seems to occupy the browser window. but if this is the case it is strange why the system exploit worked. on todays trunk js doesn work after print preview when js is disabled (it used  to before)

> Georgi, would you mind filing a separate bug for us to sort out whether that
> should happen?
> 

filed Bug 328961 with a testcase when js shouldn't work when print previewing a message on latest suite trunk
> ###!!! ASSERTION: no document: 'doc', file nsXULElement.cpp, line 2205

Known thing; always happens when leaving preview.  :(

Attachment #213513 - Flags: approval-branch-1.8.1?(jst) → approval-branch-1.8.1+
Is this something we should fix on the 1.8.0 and 1.7.* branches?

Fixed on the 1.8 branch.
Flags: blocking1.8.0.3?
Flags: blocking1.7.14?
Flags: blocking-aviary1.0.9?
Keywords: fixed1.8.1
Flags: blocking1.8.0.3? → blocking1.8.0.3+
Attachment #213513 - Flags: approval1.8.0.3?
Comment on attachment 213513 [details] [diff] [review]
Proposed safe fix

approved for 1.8.0 branch, a=dveditz for drivers
Attachment #213513 - Flags: approval1.8.0.3? → approval1.8.0.3+
Keywords: fixed1.8.0.3
verified with: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060505 Firefox/1.5.0.4
This is more of a Denial of Service problem now (as opposed to the more critical issue in bug 328469 where this testcase comes from), right? Please correct me if sg:low is not appropriate.
Whiteboard: [sg:low]
(In reply to comment #20)
> This is more of a Denial of Service problem now (as opposed to the more
> critical issue in bug 328469 where this testcase comes from), right? Please
> correct me if sg:low is not appropriate.
> 

i don't mind sg:low. bug 328469 where this testcase comes from is dangerous.
Group: security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: