Closed Bug 307989 Opened 19 years ago Closed 19 years ago

Crash [@ GetWrapperFor] [@ nsIView::GetViewFor] dragging selection within evil changing document

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, defect, P1)

PowerPC
macOS
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: dbaron)

References

Details

(Keywords: crash, verified1.8.0.2, verified1.8.1, Whiteboard: [sg:critical?][patch][rft-dl] trunk(1.9) only)

Crash Data

Attachments

(1 file)

Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.9a1) Gecko/20050910 Firefox/1.6a1 Steps to reproduce: 1. Open the very evil testcase. 2. Select some text and start dragging it. (You can use the keyboard to select all before dragging with the mouse.) 3. Wait until the page changes. 4. Drop. Result: More often than not, the browser crashes [@ nsIView::GetViewFor] [@ GetWrapperFor]. The top of the stack is a random address. I'm pretty sure this is exploitable. TB9234593K, TB9234571Z Please keep this security-sensitive until a Firefox release with this fix has gone out and both bug 306663 and bug 306939 have become public.
Attached file very evil testcase
Whiteboard: [sg:fix]
I can't get it to crash on Windows. On Windows, the script is paused until I drop what I'm dragging.
Flags: blocking1.8b5?
Flags: blocking1.8b5? → blocking1.8b5+
ROC, can you help us look into these crashes?
I can't get it to crash on Linux.
Pulling off 1.5b2 list for now. Mac-only, requires a specific set of steps to cause. Putting on Josh A. radar to see if there is an easy fix
Assignee: nobody → joshmoz
Flags: blocking1.8b5+ → blocking1.8b5-
Still crashes using Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.9a1) Gecko/20051018 Firefox/1.6a1. TB10831987H
Assignee: joshmoz → dbaron
The problem here is that the nsMouseEvent cached in the nsSelection object is pointing to a stale widget. We should probably store some information other than an nsMouseEvent in the *DelayedCaretData functions, i.e., store something like what we do with the result in the one user of GetDelayedCaretData. (There are multiple implementations, since one forwards to the other.)
So this code is called only when you click in a selection and don't move far enough for the movement to be considered a drag. What we currently do is use the coordinates of the click start to call GetContentAndOffsetsFromPoint in the frame in which the click ends. (You can move a few pixels without starting a drag, enough to get to a different line in a textarea.) We could fix this by doing the GetContentAndOffsetsFromPoint call up front and thus being consistent about using the start coordinates of the click. But that seems silly, since one usually uses the end coordinates of a click. The thing is, we normally do do selection for movements that aren't large enough to be considered a drag, so there really isn't a normal behavior for where to place a caret when the start and end of the click are at two different points -- normally you'd end up with a selection. But I think it seems like it would be fine to just use the end coordinate of the click, which removes the need for storing any of this information at all.
Attached patch patchSplinter Review
Attachment #206040 - Flags: superreview?(roc)
Attachment #206040 - Flags: review?(roc)
(And thanks to Sicking for helping debug this.)
Status: NEW → ASSIGNED
Priority: -- → P1
Whiteboard: [sg:fix] → [sg:fix][patch]
Comment on attachment 206040 [details] [diff] [review] patch I wonder if we really need the delayed caret data at all.
Attachment #206040 - Flags: superreview?(roc)
Attachment #206040 - Flags: superreview+
Attachment #206040 - Flags: review?(roc)
Attachment #206040 - Flags: review+
Fix checked in to trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Attachment #206040 - Flags: approval1.8.1?
Attachment #206040 - Flags: approval1.8.0.1?
Let's bake a couple more days on the trunk and then consider for 1.8.0.1.
Flags: blocking1.8.1+
Flags: blocking1.8.0.1+
Whiteboard: [sg:fix][patch] → [sg:critical?][patch]
Attachment #206040 - Flags: approval1.8.1?
Attachment #206040 - Flags: approval1.8.1+
Attachment #206040 - Flags: approval1.8.0.1?
Attachment #206040 - Flags: approval1.8.0.1+
So, when I tried to merge the nsFrame.cpp changes, I discovered that the code is different on the branch -- I think different enough that the crash bug is not present and this fix won't actually do anything useful. I want to double-check this a little more carefully, later, though.
I'm not seeing a crash on the 1.8 branch -- can someone else confirm that? If it's not crashing this doesn't need to block 1.8.0.x
Keywords: qawanted
May not happen on 1.8 branch, slip nomination to 1.8.0.2 for reconsideration whether we need this or not.
Flags: blocking1.8.0.2?
Flags: blocking1.8.0.1-
Flags: blocking1.8.0.1+
Attachment #206040 - Flags: approval1.8.1?
Attachment #206040 - Flags: approval1.8.1+
Attachment #206040 - Flags: approval1.8.0.2?
Attachment #206040 - Flags: approval1.8.0.1-
Attachment #206040 - Flags: approval1.8.0.1+
Flags: testcase+
Attachment #206040 - Flags: approval1.8.1? → branch-1.8.1?(roc)
I think we should take just the nsSelection.cpp half of the patch on the branches -- doing so would turn any crash that exists (but I don't think it does) from something potentially exploitable into a null dereference. I don't see a need to attach a new patch for that, but if somebody thinks I need to, let me know.
Can't really a= the wrong patch, but a=dveditz on 1.8.0.2 for the proposed smaller patch
Flags: blocking1.8.0.2? → blocking1.8.0.2+
Attachment #206040 - Flags: branch-1.8.1?(roc)
Attachment #206040 - Flags: approval1.8.0.2?
nsSelection.cpp change checked in to MOZILLA_1_8_BRANCH and MOZILLA_1_8_0_BRANCH
Does this still need qawanted? It looks like comment #15 wanted QA on the 1.8. But we already have a fix on 1.8.1 branch so it looks like we past that now.
Only half the fix was landed on the branches; that fix would either (a) have no effects or (b) turn a rare potentially exploitable crash into a slightly more common null dereference crash. I think it's probably safe to assume it's (a) unless somebody reports the crash, although some testing that that's actually the case could be useful.
davel or bclary- can you look at dbaron's comment 21 an provide some testing there?
I've looked at the code, and talked briefly to dbaron, and I'm not sure that there is a good way to do directed testing regarding the patch that landed on the branch. If we're concerned about this fix, then I one sugestion I have is that we instrument the code (perhaps by setting the widget pointer to a known bad address rather than nsnull), then do a manual mouse-event torture-test with caret-browsing on and off. Do we have trace or static analysis tools that can figure out the lifecycle (possible or actual) of event objects? That kind of thing would help direct our testing.
removing qawanted keyword - we'll verify using the test case and poking around if we have the opportunity
Keywords: qawanted
Whiteboard: [sg:critical?][patch] → [sg:critical?][patch][rft-dl]
verified on 1.8.0.2 using Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060301 Firefox/1.5.0.1. Unable to crashy despite repeated manipulations of the evil test case. Hopefully it isn't poised to take over the world. Adding relevant keyword.
Whiteboard: [sg:critical?][patch][rft-dl] → [sg:critical?][patch]
Comment on attachment 206040 [details] [diff] [review] patch The nsSelection.cpp part of this patch was the only part checked in elsewhere, and it still applies cleanly to the older branch. It would be good to take for the reasons cited in comment 17.
Attachment #206040 - Flags: approval1.7.13?
Attachment #206040 - Flags: approval-aviary1.0.8?
Whiteboard: [sg:critical?][patch] → [sg:critical?][patch][rft-dl]
Comment on attachment 206040 [details] [diff] [review] patch We are already past code freeze and the general testing is done. "-" for 1.0.8. "?" for 1.0.9.
Attachment #206040 - Flags: approval1.7.13?
Attachment #206040 - Flags: approval1.7.13-
Attachment #206040 - Flags: approval-aviary1.0.9?
Attachment #206040 - Flags: approval-aviary1.0.8?
Attachment #206040 - Flags: approval-aviary1.0.8-
Flags: blocking1.7.14?
Flags: blocking-aviary1.0.9?
Flags: blocking1.7.14?
Flags: blocking-aviary1.0.9?
Whiteboard: [sg:critical?][patch][rft-dl] → [sg:critical?][patch][rft-dl] trunk(1.9) only
verified on 1.8.1 using Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1b1) Gecko/20060810 BonEcho/2.0b1. Unable to crash despite repeated manipulations of the evil test case. Adding keyword.
Flags: in-testsuite+ → in-testsuite?
Group: security
Crash Signature: [@ GetWrapperFor] [@ nsIView::GetViewFor]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: