Closed
Bug 326501
Opened 19 years ago
Closed 19 years ago
Content can implement tree views and trigger memory corruption
Categories
(Core :: XUL, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: bzbarsky, Assigned: roc)
References
Details
(Keywords: fixed1.8.1, testcase, verified1.8.0.4, Whiteboard: [sg:critical?] [need testing on 1.7 branch with 1.7 branch tree apis])
Attachments
(4 files)
1.13 KB,
application/vnd.mozilla.xul+xml
|
Details | |
1.16 KB,
application/vnd.mozilla.xul+xml
|
Details | |
1.20 KB,
application/vnd.mozilla.xul+xml
|
Details | |
12.10 KB,
patch
|
bzbarsky
:
review+
bzbarsky
:
superreview+
bzbarsky
:
approval-branch-1.8.1+
dveditz
:
approval1.8.0.4+
|
Details | Diff | Splinter Review |
See bug 325236. The testcase there exploits a bug in page info, but content can just implement a tree view itself and stick alerts in it, thus leading to dead rendering surfaces. Jag has a testcase he's going to attach.
On trunk, cairo will make the gfx code in question die, but we're still left with arbitrary JS running (and triggering DOM mutations, reflow, etc) while inside Paint(). That's really not a good idea.
Options I see:
1) Disallow unprivileged tree views.
2) Change trees somehow to not call into the view during Paint()
Any other ideas?
This probably affects at least the 1.8 branch; we might be safe on 1.7 with the old tree API; not sure.
Comment 1•19 years ago
|
||
![]() |
Reporter | |
Updated•19 years ago
|
Flags: blocking1.9a1?
Flags: blocking1.8.1?
Flags: blocking1.8.0.2?
Whiteboard: [need testing on 1.7 branch with 1.7 branch tree apis]
Assignee | ||
Comment 2•19 years ago
|
||
2) would be ideal. We'd like to support trees for untrusted content.
![]() |
Reporter | |
Comment 3•19 years ago
|
||
Agreed. The problem is I'm not sure how much of the tree arch (and especially performance) is tied to calling getCellText() only in Paint()...
Note also that any getCellText() call can destroy the tree frame. So doing anything after calling getCellText() is no good, pretty much.
![]() |
Reporter | |
Updated•19 years ago
|
Group: security
Comment 4•19 years ago
|
||
The whole tree arch depends on calling tree view methods during Paint().
If you want to avoid it, you will have to cache it somehow, but that would lead to much increased memory footprint IMO.
(In reply to comment #4)
> The whole tree arch depends on calling tree view methods during Paint().
> If you want to avoid it, you will have to cache it somehow, but that would lead
> to much increased memory footprint IMO.
One solution is to disallow unprivileged tree models, and then provide one (or more) tree model implementations that unprivileged content can use. For example, one that lets you set up # of columns, and then has addrow/deleterow/setvalue operations on it; all the TreeView callbacks would go to the well-behaved model impl, which would have all the data in memory. I don't think unprivileged content will be doing all that interesting things with native trees anyway..
Comment 6•19 years ago
|
||
is this linux only?
don't crash on win32/wine
Comment 7•19 years ago
|
||
don't crash on mac osx
Comment 8•19 years ago
|
||
(In reply to comment #5)
>One solution is to disallow unprivileged tree models, and then provide one (or
>more) tree model implementations that unprivileged content can use.
Trees default to the DOM model (there are cases where they get the RDF model but that's only useful for sorting). How would they access these other models?
Assignee | ||
Comment 9•19 years ago
|
||
(In reply to comment #5)
> I don't think unprivileged content will be doing all that interesting things
> with native trees anyway..
I don't want to assume this.
However, it seems to me that the best architecture for "asychronous" untrusted tree views (where tree cell data is not fetched during Paint, but Paint triggers loading of cell data with update of the tree when the data arrives, and cell data is cached and prefetched for performance/responsiveness) would be to have a regular synchronous, trusted treeview implementation which delegates to the untrusted one --- keeps the complexity out of the already-nasty tree code. So then, I say we go for requiring treeviews to be trusted.
![]() |
Reporter | |
Comment 10•19 years ago
|
||
So perhaps when a view is being set we should just check whether the caller context is system and if it's not wrap the view being set in a trusted one? If we could check whether the view being set is already trusted that would be nice too; perhaps if it is get the underlying view and rewrap it (I don't think we want to assume anything about the claims of a tree view to being trusted).
Comment 11•19 years ago
|
||
So, how is this trusted view supposed to work? At the moment, I'm guessing:
* The frame makes a request
* The view logs that the request was made
* The view queues an event (if there isn't one already queued)
* The view returns the last cached value
* The event fires
* The view queries the script for the actual value(s)
* For each value that has changed, the view requests a repaint
![]() |
Reporter | |
Comment 12•19 years ago
|
||
Yeah, that sounds about right to me.
![]() |
Reporter | |
Comment 13•19 years ago
|
||
Though the view also needs to have some provisions for dropping data at times, possibly... otherwise it seems like unbounded memory growth can happen easily.
Comment 14•19 years ago
|
||
modifying the testcase
getImageSrc: function(row,col){ return "javascript:alert(this)"; },
gives a strange warning:
JavaScript error: , line 0: uncaught exception: Permission denied to get property Window.alert
don't know in what context the js is tried to execute.
Comment 15•19 years ago
|
||
![]() |
Reporter | |
Comment 16•19 years ago
|
||
> don't know in what context the js is tried to execute.
The JS context was that of the window involved. The security context was the one created from the "javascript:" URI (basically, as close to the non-principal as we can get right now). See http://lxr.mozilla.org/seamonkey/source/dom/src/jsurl/nsJSProtocolHandler.cpp#245
Assignee | ||
Comment 17•19 years ago
|
||
(In reply to comment #11)
> So, how is this trusted view supposed to work? At the moment, I'm guessing:
> * The frame makes a request
> * The view logs that the request was made
> * The view queues an event (if there isn't one already queued)
> * The view returns the last cached value
> * The event fires
> * The view queries the script for the actual value(s)
> * For each value that has changed, the view requests a repaint
Something like that, but that discussion belongs in a different bug. We should make this bug just be about requiring tree views to be trusted.
Comment 18•19 years ago
|
||
(In reply to comment #13)
> Though the view also needs to have some provisions for dropping data at times,
> possibly... otherwise it seems like unbounded memory growth can happen easily.
>
We might end up with building real content and frames after all :)
The tree widget is quite complex and "nasty" because it implements many things on its own for performance reasons.
The old tree widget was buggy and slow, but it supported almost the same API as other widgets, so it didn't confuse XUL developers as the current widget does.
The outliner/new tree widget is very fast, but it has grown into a monster and doesn't fit the current layout code or plans for other layout changes in future.
There are other things like in-line editing (textbox, menulist), arbitrary content in rows, rows with different height.
These things are hard to implement and would make things even more complex.
Maybe it's time to design tree widget v3 :)
My $0.02
Assignee | ||
Comment 19•19 years ago
|
||
I think it should be possible to design a new high-performance, high-function tree widget with little or no Gecko support. Make the core of it an overflow:hidden box. On scrolling, just shuffle around the content children and/or repopulate them with new data. But that discussion also belongs elsewhere...
Comment 20•19 years ago
|
||
(In reply to comment #19)
> I think it should be possible to design a new high-performance, high-function
> tree widget with little or no Gecko support. Make the core of it an
> overflow:hidden box. On scrolling, just shuffle around the content children
> and/or repopulate them with new data. But that discussion also belongs
> elsewhere...
>
Yeah, that would be great.
I just wanted to express my opinion on that.
Comment 21•19 years ago
|
||
(In reply to comment #19)
>I think it should be possible to design a new high-performance, high-function tree
>widget with little or no Gecko support. Make the core of it an overflow:hidden box.
Isn't that what a <listbox> is trying to be?
Comment 22•19 years ago
|
||
(In reply to comment #21)
> (In reply to comment #19)
> >I think it should be possible to design a new high-performance, high-function tree
> >widget with little or no Gecko support. Make the core of it an overflow:hidden box.
> Isn't that what a <listbox> is trying to be?
>
I think listbox is overflow-y:auto
Someone please file a new bug for new tree design.
Comment 23•19 years ago
|
||
making the testcase a little more invalid produces this bad sounding assertion:
###!!! ASSERTION: XPConnect is being called on a scope without a 'Components' property!
This is pretty much always bad. It usually means that native code is
making a callback to an interface implemented in JavaScript, but the
document where the JS object was created has already been cleared and the
global properties of that document's window are *gone*. Generally this
indicates a problem that should be addressed in the design and use of the
callback code.
: 'Error', file /opt/firefox-cvs/mozilla/js/src/xpconnect/src/xpcwrappednativescope.cpp, line 589
Break: at file /opt/firefox-cvs/mozilla/js/src/xpconnect/src/xpcwrappednativescope.cpp, line 589
###!!! ASSERTION: XPConnect is being called on a scope without a 'Components' property!
Comment 24•19 years ago
|
||
Comment 25•19 years ago
|
||
"assert no Components" must be reloaded for the assertion.
Comment 26•19 years ago
|
||
Isn't looking like a 1.8.0.2 patch is a reasonable expectation.
Flags: blocking1.8.0.2? → blocking1.8.0.2-
Updated•19 years ago
|
Flags: blocking1.8.0.3?
Comment 27•19 years ago
|
||
Any thoughts on how to workaround this bug for 1.8.0.x? Any takers?
![]() |
Reporter | |
Comment 28•19 years ago
|
||
Comment 11 is about it, as far as I can tell.
Assignee | ||
Comment 29•19 years ago
|
||
I thought we were just going to go with comment #10 and disable tree views from untrusted content.
Comment 30•19 years ago
|
||
OK. Is someone willing to cut a patch for that?
Assignee | ||
Comment 31•19 years ago
|
||
I'm working on it. Actually we only need to disable untrusted content setting a non-native tree view.
Assignee | ||
Comment 33•19 years ago
|
||
Fairly simple. The psuedointerface approach to marking treeviews as usable by untrusted script isn't ideal, perhaps, but it's good enough as far as I can tell.
Attachment #216077 -
Flags: superreview?(bzbarsky)
Attachment #216077 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 34•19 years ago
|
||
Note that if we land this, we need to tell XUL developers somehow.
Comment 35•19 years ago
|
||
What is this code trying to accomplish? Disable using custom nsITreeViews from remote content?
If so, allowing setting it to anything doesn't serve any purpose for remote content. You seem to be explicitly allowing it to be set to the builder view, which will already be set automatically if needed, and the sql database view (not built by default), which doesn't make any sense since it can't be used from remote content anyway.
Assignee | ||
Comment 36•19 years ago
|
||
OK. Is it okay to assume that we won't add any other tree views that we want to make accessible to remote XUL?
![]() |
Reporter | |
Comment 37•19 years ago
|
||
Given the number of bugs we've had filed that used custom tree views, I'm not sure whether disabling custom tree views will break xul-based intranet apps... I say "not sure" because those testcases may have been reduced from extensions, of course.
Hence the proposal to have a built-in wrapper for these custom views -- it would allow us to make this safe without regressing functionality (hopefully).
Assignee | ||
Comment 38•19 years ago
|
||
That is considerably more work and I hadn't really intended to suggest that approach as a security fix. Getting it right wouldn't be easy, and I suspect that it'd be simpler and more reliable for intranet apps to just get UniveralBrowserWrite.
![]() |
Reporter | |
Comment 39•19 years ago
|
||
Comment on attachment 216077 [details] [diff] [review]
fix
OK, fair enough.
>Index: content/base/src/nsContentUtils.cpp
>+ if (nsContentUtils::IsCallerChrome())
>+ return PR_TRUE;
Not sure it's really worth doing this check up front, since for chrome all capabilities are always enabled and figuring that out is pretty fast. I'd just do the capability checks here.
r+sr=bzbarsky with that.
Attachment #216077 -
Flags: superreview?(bzbarsky)
Attachment #216077 -
Flags: superreview+
Attachment #216077 -
Flags: review?(bzbarsky)
Attachment #216077 -
Flags: review+
Updated•19 years ago
|
Flags: blocking1.9a1?
Flags: blocking1.9a1+
Flags: blocking1.8.1?
Flags: blocking1.8.1+
Flags: blocking1.8.0.3?
Flags: blocking1.8.0.3+
Flags: blocking1.7.14?
Flags: blocking-aviary1.0.9?
Updated•19 years ago
|
Whiteboard: [need testing on 1.7 branch with 1.7 branch tree apis] → [sg:critical?] [need testing on 1.7 branch with 1.7 branch tree apis]
Assignee | ||
Comment 40•19 years ago
|
||
checked in.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 41•19 years ago
|
||
Comment on attachment 216077 [details] [diff] [review]
fix
Need branch approvals for this 1.8.1/1.8.0.3 blocker.
Attachment #216077 -
Flags: approval1.8.0.3?
Attachment #216077 -
Flags: approval-branch-1.8.1?(bzbarsky)
![]() |
Reporter | |
Updated•19 years ago
|
Attachment #216077 -
Flags: approval-branch-1.8.1?(bzbarsky) → approval-branch-1.8.1+
Comment 42•19 years ago
|
||
today linux trunk doesn't crash on the testcases and gives error
Error: uncaught exception: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "chrome://global/content/bindings/tree.xml Line: 0"]
Comment 43•19 years ago
|
||
Comment on attachment 216077 [details] [diff] [review]
fix
approved for 1.8.0 branch, a=dveditz for drivers
Attachment #216077 -
Flags: approval1.8.0.3? → approval1.8.0.3+
Comment 45•19 years ago
|
||
v.fixed on 1.8.0 branch: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060420 Firefox/1.5.0.2, no crash, but I see the same exception as Georgi:
Error: uncaught exception: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "chrome://global/content/bindings/tree.xml Line: 0"]
If there are any other testcases that will test whether or not this will break existing functionality, please let us know.
Updated•19 years ago
|
Group: security
Component: XP Toolkit/Widgets: Trees → XUL
QA Contact: xptoolkit.trees → xptoolkit.widgets
You need to log in
before you can comment on or make changes to this bug.
Description
•