Bugzilla@Mozilla – Bug 634983
Use-after-free vulnerability in OBJECT's mObserverList (ZDI-CAN-1033)
Last modified: 2011-05-09 13:27:10 PDT
Summon comment box
The following was reported to security@mozilla.org by ZDI: ZDI-CAN-1033: Mozilla Firefox OBJECT mObserverList Remote Code Execution Vulnerabililty -- CVSS ---------------------------------------------------------------- 9, (AV:N/AC:L/Au:N/C:P/I:P/A:C) -- ABSTRACT ------------------------------------------------------------ TippingPoint has identified a vulnerability affecting the following products: Mozilla Firefox -- VULNERABILITY DETAILS ----------------------------------------------- This vulnerability allows remote attackers to execute arbitrary code on vulnerable installations of Mozilla Firefox. User interaction is required to exploit this vulnerability in that the target must visit a malicious page or open a malicious file. The specific flaw exists within Firefox's handling of observer OBJECTs. If an observer OBJECT is removed from the mObserverList during an iteration of LOOP_OVER_OBSERVERS macro, one can heap spray over |mObserverList.mNext| and change the execution flow. This would allow the attacker to execute arbitrary code under the context of the user running the browser. Version(s) tested: Firefox 3.6.13 Platform(s) tested: Windows XP SP3 As the OBJECT element implements nsIImageLoadingContent interface it is possible to register custom observer (implementing imgIDecoderObserver) and force our OBJECT removal during e.g. onStartContainer| callback (other hooks are probably dangerous as well). That would also destroy object's observers linked list, |mObserverList|. If that happens during iteration of LOOP_OVER_OBSERVERS macro one can heap spray over |mObserverList.mNext| and change the execution flow. From content/base/src/nsObjectLoadingContent.cpp: // Macro to call some func on each observer. This handles observers // removing themselves. #define LOOP_OVER_OBSERVERS(func_) \ PR_BEGIN_MACRO \ for (ImageObserver* observer = &mObserverList, *next; observer; \ observer = next) { \ next = observer->mNext; \ if (observer->mObserver) { \ observer->mObserver->func_; \ } \ } \ PR_END_MACRO -- CREDIT -------------------------------------------------------------- This vulnerability was discovered by: * regenrecht
This looks like it's saying "a Firefox extension could do something critically bad by implementing imgIDecoderObserver". That's not a security flaw in itself.
Looks like on 3.6 untrusted content can call addObserver. We don't allow that on trunk.
Created attachment 513198 [details] Testcase showing the problem (won't crash or anything)
Moving to 1.9.2 branch per comment 2.
On trunk this was fixed in bug 604262. We should probably just backport that patch.
And I'd add a dep, but that bug is public, so....
Verified not to be affected on the 1.9.1 nightly.
Al, how did you verify that exactly? I would expect 1.9.1 to have this problem.
To be clear, if you're using the attached testcase, the build is unaffected if opening the testcase shows an exception in the error console. If there is no exception, then the build has this bug.
(In reply to comment #8) > Al, how did you verify that exactly? I would expect 1.9.1 to have this > problem. I believe he ran the testcase from bug 604262 in Firefox 3.5 and didn't see the crash. Was that an incorrect verification?
Yes. The testcase in that bug doesn't crash in Firefox 3.6 either, for whatever reason, whereas this bug is clearly present in 3.6, right?
I checked the testcase in bug 604262 as Brandon asked me to do in triage today since I had a 1.9.1 system running at the moment. If that is wrong, we can change the 1.9.1 status. I didn't even look at 1.9.2 since we were in triage and wondering about 1.9.1.
There is no exception from the testcase in 3.5.18pre
This is fixed for 1.9.2, moving to 1.9.1.
This is fixed in Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19 for 1.9.1.19. I see an exception in the error console: Error: uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIImageLoadingContent.addObserver]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: https://bug634983.bugzilla.mozilla.org/attachment.cgi?id=513198&t=DRUAWvZtUR :: <TOP_LEVEL> :: line 5" data: no] This exception wasn't present in 1.9.19 build 1 (before we fixed this). BTW, I see the same message in 1.9.2.17.
Marking fixed as this landed on all relevant branches, marking fixed.