Closed
Bug 291653
Opened 20 years ago
Closed 13 years ago
Event handlers can fire with window.document set to new document
Categories
(Core :: DOM: Events, defect)
Core
DOM: Events
Tracking
()
RESOLVED
FIXED
People
(Reporter: bryner, Assigned: smaug)
References
Details
(Whiteboard: [sg:moderate])
Attachments
(1 file)
3.75 KB,
patch
|
jst
:
review+
|
Details | Diff | Splinter Review |
There is a small window of time between the time we begin parsing a new document
and the time that the old document is destroyed (250ms, the paint suppression
delay). During this time, it is still possible for event handlers in the old
document to fire if they were initiated by a user action. When this happens,
window.document will be set to the newly-loading document, so the event handler
can grab whatever it wants from there. Through some creative use of event
handlers (like mousemove), a malicious site could make it quite easy for a user
to trigger the event handler.
I discovered this in the context of a larger set of testing for fast back, so I
will try to reduce the testcase and post it here.
Reporter | ||
Comment 1•20 years ago
|
||
I may have overstated the extent of this bug. I can only get it to happen when
the new URL is on the same server as the old page. Feel free to mark invalid if
this is as intended.
Comment 2•20 years ago
|
||
Is a same-origin check suppressing any across servers? That's cool, but it
still does not match what happened with Netscape 2-4. Maybe Gecko has always
been this way, though. I'm pretty sure IE isolates documents, using distinct
inner window objects (which would help us in a couple of different ways: faster
yet safe caching of object principals; set-aside rather than copy-out/in for
fast-back navigation; this bug).
/be
Comment 3•20 years ago
|
||
The events should still be firing, but they should be firing on the original
document, for sure.
Comment 4•20 years ago
|
||
> Is a same-origin check suppressing any across servers?
Almost certainly.
We have existing bugs on this, actually, mostly filed on the errors event
handlers get (because the window scope has been cleared, so the functions, etc,
they expect aren't there).
Whiteboard: DUPEME
Updated•19 years ago
|
Depends on: splitwindows
Comment 5•17 years ago
|
||
should we close this out, or re-evaluate this area after all the event and wrapper work that has gone on in the last 2 years?
Comment 6•17 years ago
|
||
The bug as filed is still here. "window" is the outer window, so window.document is the new document, as described in comment 0. The window scope is not cleared anymore, so more stuff will "work".
I'm not really sure what comment 3 is trying to say. Say I have the following:
var win = window.open();
Then in the newly opened window I have an event handler that compares window.document and parent.win.document. I would expect to get back the same document from both.
Updated•17 years ago
|
Whiteboard: DUPEME → sg:? DUPEME
Updated•16 years ago
|
Whiteboard: sg:? DUPEME
Comment 7•16 years ago
|
||
Marking "sg:moderate" for now, however with some open questions regarding what sort of stuff will work now.
a) is the issue still same-origin only?
b) does it still require user interaction?
May re-evaluate severity based upon a) and b)
Updated•16 years ago
|
Whiteboard: [sg:moderate]
Comment 8•16 years ago
|
||
A testcase would be good here... Is it possible to do anything bad with this? Don't security checks prevent any real access to the document?
Assignee | ||
Comment 9•16 years ago
|
||
Yes, a testcase would be great, because things have changed since 2005.
Comment 10•13 years ago
|
||
Olli, can you help drive this forward, or decide that this is a non-issue and close this out? We're unlikely to get a testcase here unless we write it ourselves, if we can't do that we should close this as incomplete, or somesuch.
Assignee: events → Olli.Pettay
Assignee | ||
Comment 11•13 years ago
|
||
This should be fixed long ago. When window.document is set to new document, outer window should
already have a new inner window, which means that the listeners in the old inner window don't fire
anymore.
But I'll try to verify this somehow.
Comment 12•13 years ago
|
||
Olli, any luck verifying here?
Assignee | ||
Comment 13•13 years ago
|
||
This is just based on code inspection:
For nodes in the document nsContentUtils::GetContextForEventHandlers uses
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDocument.cpp?mark=3854-3857#3843
which checks that right innerWindow is used (fix for Bug 403167).
But I'm not yet sure about window handling. Looking some more code...
Assignee | ||
Comment 14•13 years ago
|
||
So window event handlers can run when new document is set, but that works only with
same origin documents.
It is not yet clear what prevent that with different origin docs.
I don't see exceptions but somehow http://mxr.mozilla.org/mozilla-central/source/js/xpconnect/src/XPCWrappedJSClass.cpp#1533 fails.
Anyway, I think we should handle windows like we handle nodes: if innerWindow isn't the current
innerwindow, listener shouldn't run.
Assignee | ||
Comment 15•13 years ago
|
||
bholley says that XOW does the security check in this case.
I still wonder why there isn't any security warning in the error console.
Comment 16•13 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #14)
> Anyway, I think we should handle windows like we handle nodes: if
> innerWindow isn't the current innerwindow, listener shouldn't run.
Agreed.
Assignee | ||
Comment 17•13 years ago
|
||
Make event listener handling more consistent.
Attachment #568951 -
Flags: review?(jst)
Updated•13 years ago
|
Attachment #568951 -
Flags: review?(jst) → review+
Assignee | ||
Comment 18•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Updated•9 years ago
|
Group: core-security → core-security-release
Updated•9 years ago
|
Group: core-security-release
You need to log in
before you can comment on or make changes to this bug.
Description
•