Closed Bug 386382 Opened 17 years ago Closed 17 years ago

1.8 branch shutdown crash after using accessibility api (testcase from bug 377470)

Categories

(Core :: Disability Access APIs, defect)

defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: dveditz, Assigned: MatsPalmgren_bugz)

References

()

Details

(4 keywords, Whiteboard: [sg:moderate?] critical if unprivileged content can trigger this)

Attachments

(2 files, 1 obsolete file)

I get a shutdown crash in 1.8.1.5pre debug builds after running the testcase from bug 377470 (https://bugzilla.mozilla.org/attachment.cgi?id=261540), stack as described at bug 377470 comment 9, dereferencing a deleted object.

So far have not reproduced the crash in an optimized build.
Flags: wanted1.8.1.x+
Attached file stack trace
nsHTMLComboboxAccessible::Init() creates the button and list accessibles
into its members using GetNextSibling().  The problem is that the
GetNextSibling methods uses mNextSibling to check if it should create
its sibling or not, but doesn't actually assign it, so any subsequent
call to GetNextSibling() will create a new ComboboxListAccessible object.
ComboboxListAccessible caches up option accessibles effectively stealing
the children of the previous one:
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp&rev=1.46.2.3&root=/cvsroot&mark=361#345

which now has an invalid mFirstChild pointer - which will eventually
crash when nsAccessible::Shutdown tries to use it.
Attached patch Patch rev. 1 (obsolete) — Splinter Review
This should fix it I think.  This code have been redesigned on trunk
(bug 278034) so this looks like a branch-only bug.
Attachment #270841 - Flags: review?(aaronleventhal)
I can reproduce this crash in Firefox 2.0.0.4 on Linux:  TB33713986Z
Severity: normal → critical
Keywords: crash
Comment on attachment 270841 [details] [diff] [review]
Patch rev. 1

Should nsHTMLComboboxAccessible::Shutdown() also manually shutdown the mComboboxTextFieldAccessible and mComboboxButtonAccessible  (same as you did for the list)?

+ mNextSibling = *aNextSibling;
I suggest moving both of those before the if, and changing it to:
SetNextSibling(accessible);
Attachment #270841 - Flags: review?(aaronleventhal) → review+
Attached patch Patch rev. 2Splinter Review
(In reply to comment #4)
> (From update of attachment 270841 [details] [diff] [review])
> Should nsHTMLComboboxAccessible::Shutdown() also manually shutdown the
> mComboboxTextFieldAccessible and mComboboxButtonAccessible

Sure.

> + mNextSibling = *aNextSibling;
> I suggest moving both of those before the if, and changing it to:
> SetNextSibling(accessible);

This makes me a bit nervous about it:
http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/accessible/src/base/nsAccessible.cpp&rev=1.165.2.15&root=/cvsroot&mark=370#368

DEAD_END_ACCESSIBLE == 0x1 and the combobox accessible code in general
doesn't look like it would behave well with mNextSibling == 0x1.
I'd prefer to leave the null-ptr logic in these methods as is for now -
I fear for regressions if we mess to much with it.
Attachment #270927 - Flags: review?(aaronleventhal)
Attachment #270927 - Flags: review?(aaronleventhal) → review+
Attachment #270927 - Flags: approval1.8.1.5?
Attachment #270927 - Flags: approval1.8.0.13?
Attachment #270841 - Attachment is obsolete: true
Guessing at security impact. Would a user need to install something to be vulnerable to web content doing what this testcase does, or would simply turning on a screenreader or the like be sufficient?
Whiteboard: [sg:moderate?] critical if unprivileged content can trigger this
Comment on attachment 270927 [details] [diff] [review]
Patch rev. 2

approved for 1.8.1.5 and 1.8.0.13, a=dveditz
Attachment #270927 - Flags: approval1.8.1.5?
Attachment #270927 - Flags: approval1.8.1.5+
Attachment #270927 - Flags: approval1.8.0.13?
Attachment #270927 - Flags: approval1.8.0.13+
(In reply to comment #6)
Daniel,  I think one can trick the AT into creating the right set of
a11y nodes from unprivileged script by moving around focus or selection
and then remove DOM nodes or restyle elements to cause the Shutdown()
to happen.  This would setup the necessary state for either accessing
a dead node (bug 387252) or to steal the children (this bug) through
a call to GetNextSibling().  So it comes down to if one can trick the AT
to do a GetNextSibling() on the right node from script.
It doesn't seem entirely impossible to me...  Aaron?

If my guess is right then simply turning on a screenreader or other AT
would be sufficient.
MOZILLA_1_8_BRANCH:
mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp 	1.46.2.4 	mozilla/accessible/src/html/nsHTMLSelectAccessible.h 	1.28.2.2 

MOZILLA_1_8_0_BRANCH:
mozilla/accessible/src/html/nsHTMLSelectAccessible.cpp 	1.46.2.2.2.2 	mozilla/accessible/src/html/nsHTMLSelectAccessible.h 	1.28.2.1.4.1 

(trunk not affected)

-> FIXED
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Verified for 1.8.1.7 using Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.7pre) Gecko/20070822 BonEcho/2.0.0.7pre ID:2007082203 with the testcase from comment #1 and verified for 1.8.0.13 using Thunderbird 1.5.0.13 RC with Thunderbrowse - no crash

Adding verified keywords
Group: security
Flags: in-testsuite?
re-adding fixed1.8.1.5 to record when the actual fix happened, even though verification was later due to firedrills.
Keywords: fixed1.8.1.5
You need to log in before you can comment on or make changes to this bug.