Closed
Bug 430214
Opened 17 years ago
Closed 16 years ago
[FIX] Don't fire events while there are scriptblockers
Categories
(Core :: DOM: Events, defect)
Core
DOM: Events
Tracking
()
RESOLVED
FIXED
People
(Reporter: sicking, Assigned: smaug)
References
(Blocks 1 open bug)
Details
(Keywords: fixed1.9.1, Whiteboard: [sg:critical?])
Attachments
(6 files, 5 obsolete files)
(deleted),
text/html
|
Details | |
(deleted),
patch
|
sicking
:
review+
sicking
:
superreview+
beltzner
:
approval1.9.1+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
sicking
:
review+
sicking
:
superreview+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
roc
:
review+
roc
:
superreview+
beltzner
:
approval1.9.1+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
beltzner
:
approval1.9.1+
|
Details | Diff | Splinter Review |
Ideally we should make nsEventDispatcher refuse to dispatch events if there currently are scriptblockers. For now we should assert if it happens and start fixing places where it does.
Reporter | ||
Comment 1•16 years ago
|
||
Marking this as [sg:critical?] I'd be surprised if there weren't exploitable bugs here.
Whiteboard: [sg:critical?]
Assignee | ||
Comment 2•16 years ago
|
||
Jonas, should this wait for bug 430215 or could I just patch nsEventDispatcher?
Assignee: nobody → Olli.Pettay
Assignee | ||
Comment 3•16 years ago
|
||
So um, this does prevent events to be dispatched.
In some cases load and DOMContentLoaded, and also XUL's broadcast.
Have to fix those cases before landing, I guess.
Assignee | ||
Comment 4•16 years ago
|
||
Running chrome/browser-chrome/mochitest reveals also
selectedItemChanged, select, overflow and underflow.
Reporter | ||
Comment 5•16 years ago
|
||
I think we need to just assert for a while before flipping the switch. But defenitely let's try to get the assertions in and quiet asap
Assignee | ||
Comment 6•16 years ago
|
||
I don't want to remove events which have been there since 2002.
selectedItemChanged was added for XBL form controls so it isn't really used,
but some website may use it. Trying to keep it working as well as possible.
Looking at the code reveals that selectedItemChanged is evil.
Attachment #348189 -
Flags: superreview?(jonas)
Attachment #348189 -
Flags: review?(jonas)
Assignee | ||
Comment 7•16 years ago
|
||
Assignee | ||
Comment 8•16 years ago
|
||
I think at least some of the load and DOMContentLoaded happen because of
XBL documents. Those documents aren't available to scripts.
Verifying and possibly modifying https://bugzilla.mozilla.org/attachment.cgi?id=348115 to handle that case.
Assignee | ||
Comment 9•16 years ago
|
||
This reduces warnings by removing cases when scripts won't run, at least not
content scripts.
Attachment #348115 -
Attachment is obsolete: true
Assignee | ||
Comment 10•16 years ago
|
||
> Created an attachment (id=348342) [details]
With this broadcast, ValueChange (for accessibility, I think), selectedItemChanged (attachement 348189 fixes this), select, overflow and underlow events are dispatched when running chrome/browser-chrome/mochitest.
I haven't look at 'select' yet, but otherwise should be pretty easy to fix.
Assignee | ||
Comment 11•16 years ago
|
||
Assignee | ||
Comment 12•16 years ago
|
||
Comment on attachment 348362 [details] [diff] [review]
fix for 'broadcast'
This is a quick WIP. Should write some testcases and perhaps file a new bug for this.
Reporter | ||
Comment 13•16 years ago
|
||
Comment on attachment 348189 [details] [diff] [review]
patch for selectedItemChanged
Ugh, we should just remove this event IMHO. I tried googling for anyone using this event, and looked at every page that google turned up that contains 'selectedItemChanged' and 'firefox' but isn't about winforms (winforms has a feature with this name). The only thing I found was the XBL forms implementation which I found mirrored on two sites.
So it seems unlikely to me that this is used.
Assignee | ||
Comment 14•16 years ago
|
||
I don't have a strong opinion about this, so I'm happy to remove.
Attachment #348189 -
Attachment is obsolete: true
Attachment #348428 -
Flags: superreview?(jonas)
Attachment #348428 -
Flags: review?(jonas)
Attachment #348189 -
Flags: superreview?(jonas)
Attachment #348189 -
Flags: review?(jonas)
Reporter | ||
Updated•16 years ago
|
Attachment #348428 -
Flags: superreview?(jonas)
Attachment #348428 -
Flags: superreview+
Attachment #348428 -
Flags: review?(jonas)
Attachment #348428 -
Flags: review+
Assignee | ||
Comment 15•16 years ago
|
||
Assignee | ||
Comment 16•16 years ago
|
||
Comment on attachment 348362 [details] [diff] [review]
fix for 'broadcast'
Neil, would this be too ugly for 'broadcast'. This basically delays broadcast until the end the update and reuses nsDelayedBroadcastUpdate class.
Attachment #348362 -
Flags: review?(enndeakin)
Assignee | ||
Comment 17•16 years ago
|
||
Note, nsContentUtils::AddScriptRunner is null-safe.
With this and other patches running chrome/browser-chrome/mochitest gives only one warning, ValueChange somewhere in browser-chrome test.
Attachment #348552 -
Flags: superreview?(roc)
Attachment #348552 -
Flags: review?(roc)
Comment 18•16 years ago
|
||
Comment on attachment 348362 [details] [diff] [review]
fix for 'broadcast'
So EndUpdate is always called after an attribute changed?
You should probably have the other Neil look at this too.
Attachment #348362 -
Flags: review?(enndeakin) → review+
Assignee | ||
Comment 19•16 years ago
|
||
Comment on attachment 348362 [details] [diff] [review]
fix for 'broadcast'
>So EndUpdate is always called after an attribute changed?
EndUpdate is always called whenever AttributeChange is called. Both are part of the update batch.
Attachment #348362 -
Flags: superreview?(neil)
Assignee | ||
Comment 20•16 years ago
|
||
With the patches there shouldn't be any warnings.
It might be better to not have the !nsContentUtils::IsChromeDoc check,
but for now it should be enough, IMO.
Attachment #348342 -
Attachment is obsolete: true
Attachment #348565 -
Flags: superreview?(jonas)
Attachment #348565 -
Flags: review?(jonas)
+ if (nsContentUtils::IsSafeToRunScript()) {
+ CheckOverflow(parts);
+ return weakFrame.IsAlive();
+ }
+
+ nsContentUtils::AddScriptRunner(new nsOverflowChecker(this));
+ return PR_TRUE;
Why do we need the "if" block here? Can't we always just take the AddScriptRunner path?
(I do think we should return weakFrame.IsAlive() on that path though.
Assignee | ||
Comment 22•16 years ago
|
||
(In reply to comment #21)
> Why do we need the "if" block here? Can't we always just take the
> AddScriptRunner path?
>
> (I do think we should return weakFrame.IsAlive() on that path though.
We need to return weakFrame.IsAlive() if we always use AddScriptRunner.
But I was trying to reduce temporary objects, so that is the reason
for if()
I don't think we care about reducing temporary objects. Let's keep the code as simple as possible.
Assignee | ||
Comment 24•16 years ago
|
||
Attachment #348552 -
Attachment is obsolete: true
Attachment #348637 -
Flags: superreview?(roc)
Attachment #348637 -
Flags: review?(roc)
Attachment #348552 -
Flags: superreview?(roc)
Attachment #348552 -
Flags: review?(roc)
Attachment #348637 -
Flags: superreview?(roc)
Attachment #348637 -
Flags: superreview+
Attachment #348637 -
Flags: review?(roc)
Attachment #348637 -
Flags: review+
Comment 25•16 years ago
|
||
Comment on attachment 348362 [details] [diff] [review]
fix for 'broadcast'
>+ nsCOMPtr<nsIDOMElement> broadcaster = do_QueryInterface(aElement);
>+ if (broadcaster && mBroadcasterMap &&
>+ CanBroadcast(aNameSpaceID, aAttribute)) {
> nsCOMPtr<nsIDOMElement> domele = do_QueryInterface(aElement);
Just move the existing domele up?
> BroadcastListener* bl =
> static_cast<BroadcastListener*>(entry->mListeners[i]);
>
> if ((bl->mAttribute == aAttribute) ||
> (bl->mAttribute == nsGkAtoms::_asterix)) {
> nsCOMPtr<nsIContent> listener
> = do_QueryReferent(bl->mListener);
>+ nsCOMPtr<nsIDOMElement> listenerEl =
>+ do_QueryInterface(listener);
Directly query the nsIDOMElement referent?
sr=me with those fixed.
>+ ExecuteOnBroadcastHandlerFor(broadcaster,
>+ delayedAttrChangeBroadcasts[i].mListener,
>+ attrName);
I wonder why ExecuteOnBroadcastHandlerFor never used nsIContent* aListener.
Attachment #348362 -
Flags: superreview?(neil) → superreview+
Assignee | ||
Comment 26•16 years ago
|
||
Attachment #348362 -
Attachment is obsolete: true
Reporter | ||
Comment 27•16 years ago
|
||
Comment on attachment 348565 [details] [diff] [review]
warnings
Please file a follow-up bug on getting this fixed for chrome documents.
I think the biggest reason is that if something is wrong with chrome documents, it's entirely possible that it'll be wrong for things like remote XUL and the like.
Reporter | ||
Comment 28•16 years ago
|
||
Comment on attachment 348565 [details] [diff] [review]
warnings
(and of course hold off on checking this in until we're reasonably sure it won't fire too much)
Attachment #348565 -
Flags: superreview?(jonas)
Attachment #348565 -
Flags: superreview+
Attachment #348565 -
Flags: review?(jonas)
Attachment #348565 -
Flags: review+
Assignee | ||
Comment 29•16 years ago
|
||
The reason for checking chrome for now is the one ValueChange event which is
dispatched in DownloadProgressListener. I'm not quite sure what to do with
that.
Assignee | ||
Updated•16 years ago
|
Attachment #348428 -
Flags: approval1.9.1?
Assignee | ||
Updated•16 years ago
|
Attachment #348637 -
Flags: approval1.9.1?
Assignee | ||
Updated•16 years ago
|
Attachment #348737 -
Flags: approval1.9.1?
Assignee | ||
Updated•16 years ago
|
Summary: Don't fire events while there are scriptblockers → [FIX] Don't fire events while there are scriptblockers
Comment 30•16 years ago
|
||
I'm sorry - been trying to read through this bug and figure it out, but it's really hard to tell. Are all these patches being submitted for approval? Are some obsolete?
Assignee | ||
Comment 31•16 years ago
|
||
The ones with approval1.9? are fixing possible security problems where events
are dispatched at unsafe time.
"fix for 'broadcast', V2" is the same as "fix for 'broadcast'" but with
review comments addressed.
Updated•16 years ago
|
Attachment #348428 -
Flags: approval1.9.1? → approval1.9.1+
Updated•16 years ago
|
Attachment #348637 -
Flags: approval1.9.1? → approval1.9.1+
Comment 32•16 years ago
|
||
Comment on attachment 348737 [details] [diff] [review]
fix for 'broadcast', v2
a191=beltzner for these three patches; should probably create a bundle so that they land together
Attachment #348737 -
Flags: approval1.9.1? → approval1.9.1+
Assignee | ||
Comment 33•16 years ago
|
||
Actually I may want to land them separately when it is quiet time.
Assignee | ||
Updated•16 years ago
|
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Whiteboard: [sg:critical?] → [sg:critical?], [needs-1.9.1-landing]
Assignee | ||
Comment 34•16 years ago
|
||
I didn't land the "warning" patch.
Assignee | ||
Comment 35•16 years ago
|
||
Fixed on trunk and 1.9.1
https://bugzilla.mozilla.org/attachment.cgi?id=348428
https://bugzilla.mozilla.org/attachment.cgi?id=348637
https://bugzilla.mozilla.org/attachment.cgi?id=348737
Whiteboard: [sg:critical?], [needs-1.9.1-landing] → [sg:critical?]
Reporter | ||
Comment 36•16 years ago
|
||
Wait, we still don't have code in nsEventDispatcher that refuses to dispatch events even if other code attempts to while there are script-blockers, right? (The idea being a belts-and-suspenders defense-in-depth thing since ideally no one should attempt to fire events under such circumstances)
That's what this bug originally was intended for, but I'm happy to file a new bug on that since a lot of good related work in this bug has already been done.
Assignee | ||
Comment 37•16 years ago
|
||
Ah, true. New bug would be good.
Assignee | ||
Updated•16 years ago
|
Keywords: fixed1.9.1
Comment 38•15 years ago
|
||
Comment on attachment 348362 [details] [diff] [review]
fix for 'broadcast'
>@@ -970,56 +970,50 @@ nsXULDocument::AttributeChanged(nsIDocum
...
> nsAutoString value;
...
>+ nsDelayedBroadcastUpdate delayedUpdate(broadcaster,
>+ listenerEl,
>+ aAttribute,
>+ value,
>+ attrSet);
This copies value (an nsAutoString) into the mValue (an nsString), thus causing the creation of a string buffer and the copying of the value. If instead value had been made an nsString then that would have caused the creation of a string buffer, the value would have been copied there rather than an auto buffer, and then this the buffer would have been shared with mValue.
Updated•12 years ago
|
Group: core-security
You need to log in
before you can comment on or make changes to this bug.
Description
•