Skip to content
Memory corruption Disclosed report CVE-2013-0766

[FIX] Heap-use-after-free in ~nsHTMLEditRules

Abhishek Arya Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 47 days
  • Paid in 3 months
  • Disclosed after 47 days

Created attachment 673576 Testcase

Reproduces on trunk by starting multiple firefox instances (~ 4-5) with the testcase on command line.

================================================================= ==25662== ERROR: AddressSanitizer heap-use-after-free on address 0x7fed9ab46400 at pc 0x7fedd68877a0 bp 0x7fffd167aef0 sp 0x7fffd167aee8 READ of size 8 at 0x7fed9ab46400 thread T0 #0 0x7fedd688779f in ~nsHTMLEditRules editor/libeditor/html/nsHTMLEditRules.cpp:212 #1 0x7fedd688745c in ~nsHTMLEditRules editor/libeditor/html/nsHTMLEditRules.cpp:205 #2 0x7fedd623fec4 in nsTextEditRules::Release() editor/libeditor/text/nsTextEditRules.cpp:93 #3 0x7fedd6887bc7 in nsHTMLEditRules::Release() editor/libeditor/html/nsHTMLEditRules.cpp:220 #4 0x7fedd69ab0bd in nsRunnableMethodReceiver<nsHTMLEditRules, true>::Revoke() ../../../dist/include/nsThreadUtils.h:304 #5 0x7fedd69ab596 in ~nsRunnableMethodReceiver ../../../dist/include/nsThreadUtils.h:303 #6 0x7fedd69ab376 in ~nsRunnableMethodReceiver ../../../dist/include/nsThreadUtils.h:303 #7 0x7fedd69ab25d in nsRunnableMethodImpl<void (nsHTMLEditRules::)(), true>::~nsRunnableMethodImpl() ../../../dist/include/nsThreadUtils.h:333 #8 0x7fedd69aac06 in nsRunnableMethodImpl<void (nsHTMLEditRules::)(), true>::~nsRunnableMethodImpl() ../../../dist/include/nsThreadUtils.h:333 #9 0x7fedd69aad3c in nsRunnableMethodImpl<void (nsHTMLEditRules::)(), true>::~nsRunnableMethodImpl() ../../../dist/include/nsThreadUtils.h:333 #10 0x7feddcc16022 in nsRunnable::Release() objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:30 #11 0x7fedcf72428b in ~nsCOMPtr_base xpcom/build/../glue/nsCOMPtr.h:408 #12 0x7fedcf7c54e9 in nsCOMPtr<nsIRunnable>::~nsCOMPtr() ../../../dist/include/nsCOMPtr.h:447 #13 0x7fedcf7c0cc6 in nsCOMPtr<nsIRunnable>::~nsCOMPtr() ../../../dist/include/nsCOMPtr.h:447 #14 0x7fedd0a3b3b6 in nsTArrayElementTraits<nsCOMPtr<nsIRunnable> >::Destruct(nsCOMPtr<nsIRunnable>) ../../dist/include/nsTArray.h:359 #15 0x7fedd0a3b121 in nsTArray<nsCOMPtr<nsIRunnable>, nsTArrayDefaultAllocator>::DestructRange(unsigned int, unsigned int) ../../dist/include/nsTArray.h:1223 #16 0x7fedd0a3ab88 in nsTArray<nsCOMPtr<nsIRunnable>, nsTArrayDefaultAllocator>::RemoveElementsAt(unsigned int, unsigned int) ../../dist/include/nsTArray.h:943 #17 0x7fedd2f8aa9b in nsContentUtils::RemoveScriptBlocker() content/base/src/nsContentUtils.cpp:5007 #18 0x7fedd14abc6e in ~nsAutoScriptBlocker ../../../dist/include/nsContentUtils.h:2315 #19 0x7fedd14973d6 in ~nsAutoScriptBlocker ../../../dist/include/nsContentUtils.h:2314 #20 0x7fedd31ab405 in nsDocument::AdoptNode(nsIDOMNode*, nsIDOMNode**) content/base/src/nsDocument.cpp:6410 #21 0x7fedd83b0bab in nsIDOMDocument_AdoptNode(JSContext*, unsigned int, JS::Value*) objdir-ff-asan-sym/js/xpconnect/src/dom_quickstubs.cpp:1453 #22 0x7fede44440a9 in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) js/src/jscntxtinlines.h:364 #23 0x7fede43f3cc0 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) js/src/jsinterp.cpp:2372 #24 0x7fede4352cbe in js::RunScript(JSContext*, JS::Handle<JSScript*>, js::StackFrame*) js/src/jsinterp.cpp:324 #25 0x7fede44518ad in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) js/src/jsinterp.cpp:510 #26 0x7fede445353b in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) js/src/jsinterp.cpp:547 #27 0x7fede3b67a5d in JS::Evaluate(JSContext*, JS::Handle<JSObject*>, JS::CompileOptions, unsigned short const*, unsigned long, JS::Value*) js/src/jsapi.cpp:5702 #28 0x7fedd527e52e in nsJSContext::EvaluateString(nsAString_internal const&, JSObject*, nsIPrincipal*, nsIPrincipal*, char const*, unsigned int, JSVersion, nsAString_internal*, bool*) dom/base/nsJSEnvironment.cpp:1507 #29 0x7fedd543a736 in nsGlobalWindow::RunTimeoutHandler(nsTimeout*, nsIScriptContext*) dom/base/nsGlobalWindow.cpp:9701 #30 0x7fedd53f0c34 in nsGlobalWindow::RunTimeout(nsTimeout*) dom/base/nsGlobalWindow.cpp:9960 #31 0x7fedd54385e8 in nsGlobalWindow::TimerCallback(nsITimer*, void*) dom/base/nsGlobalWindow.cpp:10227 #32 0x7feddcfc3b02 in nsTimerImpl::Fire() xpcom/threads/nsTimerImpl.cpp:472 #33 0x7feddcfc500a in nsTimerEvent::Run() xpcom/threads/nsTimerImpl.cpp:555 #34 0x7feddcf88710 in nsThread::ProcessNextEvent(bool, bool*) xpcom/threads/nsThread.cpp:612 #35 0x7feddcc1957b in NS_ProcessNextEvent_P(nsIThread*, bool) objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:220 #36 0x7feddb5a75d6 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ipc/glue/MessagePump.cpp:82 #37 0x7feddd2662c1 in MessageLoop::RunInternal() ipc/chromium/src/base/message_loop.cc:215 #38 0x7feddd2660f6 in MessageLoop::RunHandler() ipc/chromium/src/base/message_loop.cc:208 #39 0x7feddd265fdb in MessageLoop::Run() ipc/chromium/src/base/message_loop.cc:182 #40 0x7feddaa4da7a in nsBaseAppShell::Run() widget/xpwidgets/nsBaseAppShell.cpp:163 #41 0x7fedd967cc54 in nsAppStartup::Run() toolkit/components/startup/nsAppStartup.cpp:290 #42 0x7fedcf7604bd in XREMain::XRE_mainRun() toolkit/xre/nsAppRunner.cpp:3792 #43 0x7fedcf766335 in XREMain::XRE_main(int, char**, nsXREAppData const*) toolkit/xre/nsAppRunner.cpp:3858 #44 0x7fedcf7691e4 in XRE_main toolkit/xre/nsAppRunner.cpp:3933 #45 0x40bb13 in do_main(int, char**) browser/app/nsBrowserApp.cpp:174 #46 0x409255 in main browser/app/nsBrowserApp.cpp:279 #47 0x7fedee6bf76c in ?? ??:0 0x7fed9ab46400 is located 0 bytes inside of 824-byte region [0x7fed9ab46400,0x7fed9ab46738) freed by thread T0 here: #0 0x4c3660 in __interceptor_free ??:? #1 0x7fedebd38406 in moz_free memory/mozalloc/mozalloc.cpp:51 #2 0x7fedd678db5d in operator delete(void*) ../../../dist/include/mozilla/mozalloc.h:224 #3 0x7fedd6275a84 in nsEditor::Release() editor/libeditor/base/nsEditor.cpp:211 #4 0x7fedd6795bd7 in nsHTMLEditor::Release() editor/libeditor/html/nsHTMLEditor.cpp:203 #5 0x7fedcf72428b in ~nsCOMPtr_base ../../../../dist/include/nsCOMPtr.h:408 #6 0x7fedd1a97149 in nsCOMPtr<nsIEditor>::~nsCOMPtr() ../../../dist/include/nsCOMPtr.h:447 #7 0x7fedd1a7f6e6 in nsCOMPtr<nsIEditor>::~nsCOMPtr() ../../../dist/include/nsCOMPtr.h:447 #8 0x7fedd9cbc0e2 in ~nsEditorSpellCheck editor/composer/src/nsEditorSpellCheck.cpp:219 #9 0x7fedd9cbbecc in ~nsEditorSpellCheck editor/composer/src/nsEditorSpellCheck.cpp:215 #10 0x7fedd9cb9254 in nsEditorSpellCheck::Release() editor/composer/src/nsEditorSpellCheck.cpp:193 #11 0x7fedcf72428b in ~nsCOMPtr_base ../../../../dist/include/nsCOMPtr.h:408 #12 0x7fedd631c389 in nsCOMPtr<nsIEditorSpellCheck>::~nsCOMPtr() ../../../dist/include/nsCOMPtr.h:447 #13 0x7fedd6295f86 in nsCOMPtr<nsIEditorSpellCheck>::~nsCOMPtr() ../../../dist/include/nsCOMPtr.h:447 #14 0x7feddb0484dd in ~mozInlineSpellChecker extensions/spellcheck/src/mozInlineSpellChecker.cpp:506 #15 0x7feddb0481cc in ~mozInlineSpellChecker extensions/spellcheck/src/mozInlineSpellChecker.cpp:505 #16 0x7feddb0456b4 in mozInlineSpellChecker::Release() extensions/spellcheck/src/mozInlineSpellChecker.cpp:479 #17 0x7feddb0701cb in ~nsRefPtr ../../../dist/include/nsAutoPtr.h:874 #18 0x7feddb06ffd6 in ~nsRefPtr ../../../dist/include/nsAutoPtr.h:872 #19 0x7feddb06fece in mozInlineSpellStatus::~mozInlineSpellStatus() extensions/spellcheck/src/mozInlineSpellChecker.h:33 #20 0x7feddb051d96 in mozInlineSpellStatus::~mozInlineSpellStatus() extensions/spellcheck/src/mozInlineSpellChecker.h:33 #21 0x7feddb06ec3d in mozInlineSpellResume::~mozInlineSpellResume() extensions/spellcheck/src/mozInlineSpellChecker.cpp:451 #22 0x7feddb06e926 in mozInlineSpellResume::~mozInlineSpellResume() extensions/spellcheck/src/mozInlineSpellChecker.cpp:451 #23 0x7feddb06ea5c in mozInlineSpellResume::~mozInlineSpellResume() extensions/spellcheck/src/mozInlineSpellChecker.cpp:451 #24 0x7feddcc16022 in nsRunnable::Release() objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:30 #25 0x7fedcf72428b in ~nsCOMPtr_base ../../../../dist/include/nsCOMPtr.h:408 #26 0x7fedcf7c54e9 in nsCOMPtr<nsIRunnable>::~nsCOMPtr() ../../dist/include/nsCOMPtr.h:447 #27 0x7fedcf7c0cc6 in nsCOMPtr<nsIRunnable>::~nsCOMPtr() ../../dist/include/nsCOMPtr.h:447 #28 0x7feddcf88810 in nsThread::ProcessNextEvent(bool, bool*) xpcom/threads/nsThread.cpp:618 #29 0x7feddcc1957b in NS_ProcessNextEvent_P(nsIThread*, bool) objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:220 previously allocated by thread T0 here: #0 0x4c3720 in malloc ??:? #1 0x7fedebd3855a in moz_xmalloc memory/mozalloc/mozalloc.cpp:57 #2 0x7fedd12ca9ee in operator new(unsigned long) ../../dist/include/mozilla/mozalloc.h:200 #3 0x7feddcc543fb in mozilla::GenericFactory::CreateInstance(nsISupports*, nsID const&, void**) objdir-ff-asan-sym/xpcom/build/GenericFactory.cpp:16 #4 0x7feddcf3289c in nsComponentManagerImpl::CreateInstanceByContractID(char const*, nsISupports*, nsID const&, void**) xpcom/components/nsComponentManager.cpp:1006 #5 0x7feddcbde0b9 in CallCreateInstance(char const*, nsISupports*, nsID const&, void**) objdir-ff-asan-sym/xpcom/build/nsComponentManagerUtils.cpp:135 #6 0x7feddcbdf48b in nsCreateInstanceByContractID::operator()(nsID const&, void**) const objdir-ff-asan-sym/xpcom/build/nsComponentManagerUtils.cpp:178 #7 0x7feddcbd2ddc in nsCOMPtr_base::assign_from_helper(nsCOMPtr_helper const&, nsID const&) objdir-ff-asan-sym/xpcom/build/nsCOMPtr.cpp:110 #8 0x7fedd4211b6e in nsCOMPtr<nsIEditor>::operator=(nsCOMPtr_helper const&) ../../../dist/include/nsCOMPtr.h:689 #9 0x7fedd9c93154 in nsEditingSession::SetupEditorOnWindow(nsIDOMWindow*) editor/composer/src/nsEditingSession.cpp:423 #10 0x7fedd9c8a600 in nsEditingSession::MakeWindowEditable(nsIDOMWindow*, char const*, bool, bool, bool) editor/composer/src/nsEditingSession.cpp:173 #11 0x7fedd4a89a3b in nsHTMLDocument::EditingStateChanged() content/html/document/src/nsHTMLDocument.cpp:2658 #12 0x7fedd4aad55c in nsHTMLDocument::MaybeEditingStateChanged() content/html/document/src/nsHTMLDocument.cpp:2304 #13 0x7fedd4aadd0d in nsHTMLDocument::EndUpdate(unsigned int) content/html/document/src/nsHTMLDocument.cpp:2317 #14 0x7fedd6600f0a in nsHtml5TreeOpExecutor::EndDocUpdate() parser/html/nsHtml5TreeOpExecutor.h:248 #15 0x7fedd6600548 in nsHtml5TreeOpExecutor::DidBuildModel(bool) parser/html/nsHtml5TreeOpExecutor.cpp:131 #16 0x7fedd65ed858 in nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor*, nsIContent**) parser/html/nsHtml5TreeOperation.cpp:639 #17 0x7fedd6604b05 in nsHtml5TreeOpExecutor::RunFlushLoop() parser/html/nsHtml5TreeOpExecutor.cpp:564 #18 0x7fedd66411e9 in nsHtml5ExecutorFlusher::Run() parser/html/nsHtml5StreamParser.cpp:127 #19 0x7feddcf88710 in nsThread::ProcessNextEvent(bool, bool*) xpcom/threads/nsThread.cpp:612 #20 0x7feddcc1957b in NS_ProcessNextEvent_P(nsIThread*, bool) objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:220 #21 0x7feddb5a75d6 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ipc/glue/MessagePump.cpp:82 #22 0x7feddd2662c1 in MessageLoop::RunInternal() ipc/chromium/src/base/message_loop.cc:215 #23 0x7feddd2660f6 in MessageLoop::RunHandler() ipc/chromium/src/base/message_loop.cc:208 #24 0x7feddd265fdb in MessageLoop::Run() ipc/chromium/src/base/message_loop.cc:182 #25 0x7feddaa4da7a in nsBaseAppShell::Run() widget/xpwidgets/nsBaseAppShell.cpp:163 #26 0x7fedd967cc54 in nsAppStartup::Run() toolkit/components/startup/nsAppStartup.cpp:290 #27 0x7fedcf7604bd in XREMain::XRE_mainRun() toolkit/xre/nsAppRunner.cpp:3792 #28 0x7fedcf766335 in XREMain::XRE_main(int, char**, nsXREAppData const*) toolkit/xre/nsAppRunner.cpp:3858 #29 0x7fedcf7691e4 in XRE_main toolkit/xre/nsAppRunner.cpp:3933 Shadow byte and word: 0x1ffdb3568c80: fd 0x1ffdb3568c80: fd fd fd fd fd fd fd fd More shadow bytes: 0x1ffdb3568c60: fa fa fa fa fa fa fa fa 0x1ffdb3568c68: fa fa fa fa fa fa fa fa 0x1ffdb3568c70: fa fa fa fa fa fa fa fa 0x1ffdb3568c78: fa fa fa fa fa fa fa fa =>0x1ffdb3568c80: fd fd fd fd fd fd fd fd 0x1ffdb3568c88: fd fd fd fd fd fd fd fd 0x1ffdb3568c90: fd fd fd fd fd fd fd fd 0x1ffdb3568c98: fd fd fd fd fd fd fd fd 0x1ffdb3568ca0: fd fd fd fd fd fd fd fd Stats: 271M malloced (1203M for red zones) by 552799 calls Stats: 45M realloced by 28360 calls Stats: 233M freed by 308733 calls Stats: 155M really freed by 234701 calls Stats: 960M (245847 full pages) mmaped in 240 calls mmaps by size class: 11:313191; 12:4096; 13:1536; 14:1280; 15:256; 16:832; 17:1216; 18:176; 19:40; 20:24; mallocs by size class: 11:539587; 12:5764; 13:2495; 14:1669; 15:381; 16:1295; 17:1349; 18:196; 19:41; 20:22; frees by size class: 11:298141; 12:3893; 13:2206; 14:1451; 15:324; 16:1189; 17:1331; 18:141; 19:38; 20:19; rfrees by size class: 11:227507; 12:2307; 13:1313; 14:1203; 15:223; 16:990; 17:1125; 18:28; 19:4; 20:1; Stats: malloc large: 1608 small slow: 9746 ==25662== ABORTING

The original report as published on Mozilla's Bugzilla, by Abhishek Arya. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A critical-severity memory corruption bug in DOM: Editor. Mozilla made it public on 7 December 2012 as CVE-2013-0766.

About Memory corruption

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Abhishek Arya

View all

130 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.