Skip to content
Memory corruption Disclosed report CVE-2012-3961

Heap-use-after-free in RangeData::~RangeData

Abhishek Arya Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 5 days
  • Paid in 12 months
  • Disclosed after 5 days

Created attachment 640025 Testcase

Reproduces on trunk 20120707214206 http://hg.mozilla.org/mozilla-central/rev/9533b40ff28b

================================================================= ==25564== ERROR: AddressSanitizer heap-use-after-free on address 0x7f1cf1264780 at pc 0x7f1d2220e700 bp 0x7fffcdd81470 sp 0x7fffcdd81468 READ of size 8 at 0x7f1cf1264780 thread T0 #0 0x7f1d2220e700 in ~nsRefPtr firefox/src/../../dist/include/nsAutoPtr.h:874 #1 0x7f1d221a42b3 in ~nsRefPtr firefox/src/../../dist/include/nsAutoPtr.h:875 #2 0x7f1d2288b4d3 in RangeData::~RangeData() firefox/src/../../dist/include/mozilla/Selection.h:24 #3 0x7f1d227ea3b3 in RangeData::~RangeData() firefox/src/../../dist/include/mozilla/Selection.h:24 #4 0x7f1d228838e3 in nsTArrayElementTraits<RangeData>::Destruct(RangeData*) firefox/src/../../dist/include/nsTArray.h:349 #5 0x7f1d228823be in nsTArray<RangeData, nsTArrayDefaultAllocator>::DestructRange(unsigned int, unsigned int) firefox/src/../../dist/include/nsTArray.h:1210 #6 0x7f1d22852ab7 in nsTArray<RangeData, nsTArrayDefaultAllocator>::RemoveElementsAt(unsigned int, unsigned int) firefox/src/../../dist/include/nsTArray.h:932 #7 0x7f1d2283db0d in mozilla::Selection::AddItem(nsRange*, int*) firefox/src/layout/generic/nsSelection.cpp:3535 #8 0x7f1d228674fe in mozilla::Selection::AddRange(nsIDOMRange*) firefox/src/layout/generic/nsSelection.cpp:4414 #9 0x7f1d2b8c58db in mozInlineSpellChecker::AddRange(nsISelection*, nsIDOMRange*) firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:1600 #10 0x7f1d2b8c2d1d in mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil&, nsISelection*, mozInlineSpellStatus*, bool*) firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:1399 #11 0x7f1d2b8c70f1 in mozInlineSpellChecker::ResumeCheck(mozInlineSpellStatus*) firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:1488 #12 0x7f1d2b8cf9dc in mozInlineSpellResume::Run() firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:462 #13 0x7f1d2d045ccd in nsThread::ProcessNextEvent(bool, bool*) firefox/src/xpcom/threads/nsThread.cpp:625 #14 0x7f1d2ccd501d in NS_ProcessNextEvent_P(nsIThread*, bool) firefox/src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:217 #15 0x7f1d2bd76226 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) firefox/src/ipc/glue/MessagePump.cpp:82 #16 0x7f1d2d2f984a in MessageLoop::RunInternal() firefox/src/ipc/chromium/src/base/message_loop.cc:209 #17 0x7f1d2d2f9693 in MessageLoop::RunHandler() firefox/src/ipc/chromium/src/base/message_loop.cc:202 #18 0x7f1d2d2f9578 in MessageLoop::Run() firefox/src/ipc/chromium/src/base/message_loop.cc:176 #19 0x7f1d2b2ae42e in nsBaseAppShell::Run() firefox/src/widget/xpwidgets/nsBaseAppShell.cpp:165 #20 0x7f1d29ef9668 in nsAppStartup::Run() firefox/src/toolkit/components/startup/nsAppStartup.cpp:257 #21 0x7f1d20736280 in XREMain::XRE_mainRun() firefox/src/toolkit/xre/nsAppRunner.cpp:3787 #22 0x7f1d2073cc22 in XREMain::XRE_main(int, char**, nsXREAppData const*) firefox/src/toolkit/xre/nsAppRunner.cpp:3864 #23 0x7f1d207400f2 in XRE_main firefox/src/toolkit/xre/nsAppRunner.cpp:3940 #24 0x40c28f in do_main(int, char**) firefox/src/browser/app/nsBrowserApp.cpp:160 #25 0x409cbd in main firefox/src/browser/app/nsBrowserApp.cpp:330 #26 0x7f1d3b388c4d in ?? ??:0 0x7f1cf1264780 is located 0 bytes inside of 64-byte region [0x7f1cf1264780,0x7f1cf12647c0) freed by thread T0 here: #0 0x4a4392 in free ??:0 #1 0x7f1d382165c3 in moz_free firefox/src/memory/mozalloc/mozalloc.cpp:49 #2 0x7f1d23d7e6c6 in ~nsRange firefox/src/content/base/src/nsRange.cpp:215 #3 0x7f1d23d82997 in nsRange::Release() firefox/src/content/base/src/nsRange.cpp:258 #4 0x7f1d2220e6a0 in ~nsRefPtr firefox/src/../../../dist/include/nsAutoPtr.h:874 #5 0x7f1d221a42b3 in ~nsRefPtr firefox/src/../../../dist/include/nsAutoPtr.h:875 #6 0x7f1d2288b4d3 in RangeData::~RangeData() firefox/src/../../dist/include/mozilla/Selection.h:24 #7 0x7f1d227ea3b3 in RangeData::~RangeData() firefox/src/../../dist/include/mozilla/Selection.h:24 #8 0x7f1d228838e3 in nsTArrayElementTraits<RangeData>::Destruct(RangeData*) firefox/src/../../dist/include/nsTArray.h:349 #9 0x7f1d228823be in nsTArray<RangeData, nsTArrayDefaultAllocator>::DestructRange(unsigned int, unsigned int) firefox/src/../../dist/include/nsTArray.h:1210 #10 0x7f1d22852ab7 in nsTArray<RangeData, nsTArrayDefaultAllocator>::RemoveElementsAt(unsigned int, unsigned int) firefox/src/../../dist/include/nsTArray.h:932 #11 0x7f1d2283db0d in mozilla::Selection::AddItem(nsRange*, int*) firefox/src/layout/generic/nsSelection.cpp:3535 #12 0x7f1d228674fe in mozilla::Selection::AddRange(nsIDOMRange*) firefox/src/layout/generic/nsSelection.cpp:4414 #13 0x7f1d2b8c58db in mozInlineSpellChecker::AddRange(nsISelection*, nsIDOMRange*) firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:1600 #14 0x7f1d2b8c2d1d in mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil&, nsISelection*, mozInlineSpellStatus*, bool*) firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:1399 #15 0x7f1d2b8c70f1 in mozInlineSpellChecker::ResumeCheck(mozInlineSpellStatus*) firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:1488 #16 0x7f1d2b8cf9dc in mozInlineSpellResume::Run() firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:462 #17 0x7f1d2d045ccd in nsThread::ProcessNextEvent(bool, bool*) firefox/src/xpcom/threads/nsThread.cpp:625 #18 0x7f1d2ccd501d in NS_ProcessNextEvent_P(nsIThread*, bool) firefox/src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:217 #19 0x7f1d2bd76226 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) firefox/src/ipc/glue/MessagePump.cpp:82 #20 0x7f1d2d2f984a in MessageLoop::RunInternal() firefox/src/ipc/chromium/src/base/message_loop.cc:209 #21 0x7f1d2d2f9693 in MessageLoop::RunHandler() firefox/src/ipc/chromium/src/base/message_loop.cc:202 #22 0x7f1d2d2f9578 in MessageLoop::Run() firefox/src/ipc/chromium/src/base/message_loop.cc:176 #23 0x7f1d2b2ae42e in nsBaseAppShell::Run() firefox/src/widget/xpwidgets/nsBaseAppShell.cpp:165 #24 0x7f1d29ef9668 in nsAppStartup::Run() firefox/src/toolkit/components/startup/nsAppStartup.cpp:257 #25 0x7f1d20736280 in XREMain::XRE_mainRun() firefox/src/toolkit/xre/nsAppRunner.cpp:3787 #26 0x7f1d2073cc22 in XREMain::XRE_main(int, char**, nsXREAppData const*) firefox/src/toolkit/xre/nsAppRunner.cpp:3864 #27 0x7f1d207400f2 in XRE_main firefox/src/toolkit/xre/nsAppRunner.cpp:3940 #28 0x40c28f in do_main(int, char**) firefox/src/browser/app/nsBrowserApp.cpp:160 #29 0x409cbd in main firefox/src/browser/app/nsBrowserApp.cpp:330 previously allocated by thread T0 here: #0 0x4a4452 in __interceptor_malloc ??:0 #1 0x7f1d38216717 in moz_xmalloc firefox/src/memory/mozalloc/mozalloc.cpp:54 #2 0x7f1d2b8dc0e3 in mozInlineSpellWordUtil::MakeRange(mozInlineSpellWordUtil::NodeOffset, mozInlineSpellWordUtil::NodeOffset, nsRange**) firefox/src/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp:322 #3 0x7f1d2b8d9fc6 in mozInlineSpellWordUtil::MakeRangeForWord(mozInlineSpellWordUtil::RealWord const&, nsRange**) firefox/src/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp:226 #4 0x7f1d2b8dee62 in mozInlineSpellWordUtil::GetNextWord(nsAString_internal&, nsRange**, bool*) firefox/src/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp:297 #5 0x7f1d2b8c1906 in mozInlineSpellChecker::DoSpellCheck(mozInlineSpellWordUtil&, nsISelection*, mozInlineSpellStatus*, bool*) firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:1317 #6 0x7f1d2b8c70f1 in mozInlineSpellChecker::ResumeCheck(mozInlineSpellStatus*) firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:1488 #7 0x7f1d2b8cf9dc in mozInlineSpellResume::Run() firefox/src/extensions/spellcheck/src/mozInlineSpellChecker.cpp:462 #8 0x7f1d2d045ccd in nsThread::ProcessNextEvent(bool, bool*) firefox/src/xpcom/threads/nsThread.cpp:625 #9 0x7f1d2ccd501d in NS_ProcessNextEvent_P(nsIThread*, bool) firefox/src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:217 #10 0x7f1d2bd76226 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) firefox/src/ipc/glue/MessagePump.cpp:82 #11 0x7f1d2d2f984a in MessageLoop::RunInternal() firefox/src/ipc/chromium/src/base/message_loop.cc:209 #12 0x7f1d2d2f9693 in MessageLoop::RunHandler() firefox/src/ipc/chromium/src/base/message_loop.cc:202 #13 0x7f1d2d2f9578 in MessageLoop::Run() firefox/src/ipc/chromium/src/base/message_loop.cc:176 #14 0x7f1d2b2ae42e in nsBaseAppShell::Run() firefox/src/widget/xpwidgets/nsBaseAppShell.cpp:165 #15 0x7f1d29ef9668 in nsAppStartup::Run() firefox/src/toolkit/components/startup/nsAppStartup.cpp:257 #16 0x7f1d20736280 in XREMain::XRE_mainRun() firefox/src/toolkit/xre/nsAppRunner.cpp:3787 #17 0x7f1d2073cc22 in XREMain::XRE_main(int, char**, nsXREAppData const*) firefox/src/toolkit/xre/nsAppRunner.cpp:3864 #18 0x7f1d207400f2 in XRE_main firefox/src/toolkit/xre/nsAppRunner.cpp:3940 #19 0x40c28f in do_main(int, char**) firefox/src/browser/app/nsBrowserApp.cpp:160 #20 0x409cbd in main firefox/src/browser/app/nsBrowserApp.cpp:330 #21 0x7f1d3b388c4d in ?? ??:0 ==25564== ABORTING Stats: 156M malloced (189M for red zones) by 464984 calls Stats: 41M realloced by 20345 calls Stats: 112M freed by 231687 calls Stats: 0M really freed by 0 calls Stats: 376M (96306 full pages) mmaped in 94 calls mmaps by size class: 8:393192; 9:49146; 10:20475; 11:18423; 12:3072; 13:2048; 14:1536; 15:384; 16:576; 17:128; 18:176; 19:48; 20:16; mallocs by size class: 8:376983; 9:47309; 10:16409; 11:17335; 12:2458; 13:1841; 14:1416; 15:336; 16:562; 17:116; 18:165; 19:41; 20:13; frees by size class: 8:163249; 9:36760; 10:12958; 11:14054; 12:1531; 13:948; 14:1228; 15:278; 16:474; 17:101; 18:58; 19:38; 20:10; rfrees by size class: Stats: malloc large: 335 small slow: 2084 Shadow byte and word: 0x1fe39e24c8f0: fd 0x1fe39e24c8f0: fd fd fd fd fd fd fd fd More shadow bytes: 0x1fe39e24c8d0: fd fd fd fd fd fd fd fd 0x1fe39e24c8d8: fd fd fd fd fd fd fd fd 0x1fe39e24c8e0: fa fa fa fa fa fa fa fa 0x1fe39e24c8e8: fa fa fa fa fa fa fa fa =>0x1fe39e24c8f0: fd fd fd fd fd fd fd fd 0x1fe39e24c8f8: fd fd fd fd fd fd fd fd 0x1fe39e24c900: fa fa fa fa fa fa fa fa 0x1fe39e24c908: fa fa fa fa fa fa fa fa 0x1fe39e24c910: fd fd fd fd fd fd fd fd

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: Selection. Mozilla made it public on 13 July 2012 as CVE-2012-3961.

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.