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

Heap-use-after-free in nsEditor::FindNextLeafNode

Abhishek Arya Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 22 days
  • Paid in 47 days
  • Disclosed after 22 days

Created attachment 666323 Testcase

Reproduces on trunk

================================================================= ==10788== ERROR: AddressSanitizer heap-use-after-free on address 0x7f236f299db8 at pc 0x7f239927cf45 bp 0x7fff229632d0 sp 0x7fff229632c8 READ of size 8 at 0x7f236f299db8 thread T0 #0 0x7f239927cf44 in nsINode::GetPreviousSibling() const src/../../dist/include/nsINode.h:1142 #1 0x7f239e1112e2 in nsEditor::FindNextLeafNode(nsINode*, bool, bool) src/editor/libeditor/base/nsEditor.cpp:3319 #2 0x7f239e1108dc in nsEditor::FindNode(nsINode*, bool, bool, bool) src/editor/libeditor/base/nsEditor.cpp:3401 #3 0x7f239e110cc1 in nsEditor::FindNode(nsINode*, bool, bool, bool) src/editor/libeditor/base/nsEditor.cpp:3411 #4 0x7f239e10ca79 in nsEditor::GetPriorNode(nsINode*, bool, bool) src/editor/libeditor/base/nsEditor.cpp:3301 #5 0x7f239e10c106 in nsEditor::GetPriorNode(nsINode*, int, bool, bool) src/editor/libeditor/base/nsEditor.cpp:3190 #6 0x7f239e649789 in nsHTMLEditor::GetPriorHTMLNode(nsINode*, int, bool) src/editor/libeditor/html/nsHTMLEditor.cpp:4104 #7 0x7f239e7c3182 in nsHTMLEditRules::GetPromotedPoint(nsHTMLEditRules::RulesEndpoint, nsIDOMNode*, int, EditAction, nsCOMPtr<nsIDOMNode>, int) src/editor/libeditor/html/nsHTMLEditRules.cpp:5277 #8 0x7f239e6d078e in nsHTMLEditRules::PromoteRange(nsIDOMRange*, EditAction) src/editor/libeditor/html/nsHTMLEditRules.cpp:5493 #9 0x7f239e6cac26 in nsHTMLEditRules::AfterEditInner(EditAction, short) src/editor/libeditor/html/nsHTMLEditRules.cpp:430 #10 0x7f239e6c8df6 in nsHTMLEditRules::AfterEdit(EditAction, short) src/editor/libeditor/html/nsHTMLEditRules.cpp:376 #11 0x7f239e63798c in nsHTMLEditor::EndOperation() src/editor/libeditor/html/nsHTMLEditor.cpp:3513 #12 0x7f239e06d372 in ~nsAutoRules src/editor/libeditor/base/nsEditorUtils.h:94 #13 0x7f239e04afc6 in ~nsAutoRules src/editor/libeditor/base/nsEditorUtils.h:91 #14 0x7f239e610e37 in nsHTMLEditor::Align(nsAString_internal const&) src/editor/libeditor/html/nsHTMLEditor.cpp:2264 #15 0x7f239e610fee in non-virtual thunk to nsHTMLEditor::Align(nsAString_internal const&) src/gfx/cairo/cairo/src/cairo-surface-subsurface.c:0 #16 0x7f23a1b430b0 in nsAlignCommand::SetState(nsIEditor*, nsString&) src/editor/composer/src/nsComposerCommands.cpp:970 #17 0x7f23a1b37113 in nsMultiStateCommand::DoCommandParams(char const*, nsICommandParams*, nsISupports*) src/editor/composer/src/nsComposerCommands.cpp:599 #18 0x7f23a13912e2 in nsControllerCommandTable::DoCommandParams(char const*, nsICommandParams*, nsISupports*) src/embedding/components/commandhandler/src/nsControllerCommandTable.cpp:175 #19 0x7f23a136257d in nsBaseCommandController::DoCommandWithParams(char const*, nsICommandParams*) src/embedding/components/commandhandler/src/nsBaseCommandController.cpp:153 #20 0x7f23a1362796 in non-virtual thunk to nsBaseCommandController::DoCommandWithParams(char const*, nsICommandParams*) src/gfx/cairo/cairo/src/cairo-surface-subsurface.c:0 #21 0x7f23a137abd3 in nsCommandManager::DoCommand(char const*, nsICommandParams*, nsIDOMWindow*) src/embedding/components/commandhandler/src/nsCommandManager.cpp:234 #22 0x7f239c901752 in nsHTMLDocument::ExecCommand(nsAString_internal const&, bool, nsAString_internal const&, bool*) src/content/html/document/src/nsHTMLDocument.cpp:3235 #23 0x7f239c902c9d in non-virtual thunk to nsHTMLDocument::ExecCommand(nsAString_internal const&, bool, nsAString_internal const&, bool*) src/gfx/cairo/cairo/src/cairo-surface-subsurface.c:0 #24 0x7f23a4ebb543 in NS_InvokeByIndex_P src/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #25 0x7f23a00bcfa8 in CallMethodHelper::Invoke() src/js/xpconnect/src/XPCWrappedNative.cpp:3110 #26 0x7f23a011e1a5 in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) src/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1469 #27 0x7f23ab687d9f in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) src/js/src/jscntxtinlines.h:370 #28 0x7f23ab629b79 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:2460 #29 0x7f23ab575aee in js::RunScript(JSContext*, JS::Handle<JSScript*>, js::StackFrame*) src/js/src/jsinterp.cpp:324 #30 0x7f23ab695566 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) src/js/src/jsinterp.cpp:509 #31 0x7f23ab6972fb in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) src/js/src/jsinterp.cpp:546 #32 0x7f23aadaa289 in JS::Evaluate(JSContext*, JS::Handle<JSObject*>, JS::CompileOptions, unsigned short const*, unsigned long, JS::Value*) src/js/src/jsapi.cpp:5679 #33 0x7f239d0c1dee in nsJSContext::EvaluateString(nsAString_internal const&, JSObject*, nsIPrincipal*, nsIPrincipal*, char const*, unsigned int, JSVersion, nsAString_internal*, bool*) src/dom/base/nsJSEnvironment.cpp:1506 #34 0x7f239d27ab76 in nsGlobalWindow::RunTimeoutHandler(nsTimeout*, nsIScriptContext*) src/dom/base/nsGlobalWindow.cpp:9621 #35 0x7f239d2326c4 in nsGlobalWindow::RunTimeout(nsTimeout*) src/dom/base/nsGlobalWindow.cpp:9880 #36 0x7f239d278a28 in nsGlobalWindow::TimerCallback(nsITimer*, void*) src/dom/base/nsGlobalWindow.cpp:10147 #37 0x7f23a4def972 in nsTimerImpl::Fire() src/xpcom/threads/nsTimerImpl.cpp:473 #38 0x7f23a4df0e7a in nsTimerEvent::Run() src/xpcom/threads/nsTimerImpl.cpp:556 #39 0x7f23a4db4580 in nsThread::ProcessNextEvent(bool, bool*) src/xpcom/threads/nsThread.cpp:612 #40 0x7f23a4a46ecb in NS_ProcessNextEvent_P(nsIThread*, bool) src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:220 #41 0x7f23a34903b6 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) src/ipc/glue/MessagePump.cpp:82 #42 0x7f23a506ce11 in MessageLoop::RunInternal() src/ipc/chromium/src/base/message_loop.cc:208 #43 0x7f23a506cc46 in MessageLoop::RunHandler() src/ipc/chromium/src/base/message_loop.cc:201 #44 0x7f23a506cb2b in MessageLoop::Run() src/ipc/chromium/src/base/message_loop.cc:175 #45 0x7f23a2937dda in nsBaseAppShell::Run() src/widget/xpwidgets/nsBaseAppShell.cpp:163 #46 0x7f23a156a9b4 in nsAppStartup::Run() src/toolkit/components/startup/nsAppStartup.cpp:290 #47 0x7f2397bdda4d in XREMain::XRE_mainRun() src/toolkit/xre/nsAppRunner.cpp:3782 #48 0x7f2397be38c5 in XREMain::XRE_main(int, char**, nsXREAppData const*) src/toolkit/xre/nsAppRunner.cpp:3848 #49 0x7f2397be6774 in XRE_main src/toolkit/xre/nsAppRunner.cpp:3923 #50 0x40d013 in do_main(int, char**) src/browser/app/nsBrowserApp.cpp:174 #51 0x40a755 in main src/browser/app/nsBrowserApp.cpp:279 #52 0x7f23b5adbc4c in ?? ??:0 0x7f236f299db8 is located 56 bytes inside of 120-byte region [0x7f236f299d80,0x7f236f299df8) freed by thread T0 here: #0 0x4c4af0 in free ??:0 #1 0x7f23b2967586 in moz_free src/memory/mozalloc/mozalloc.cpp:51 #2 0x7f239b3afccd in operator delete(void*) src/../../../dist/include/mozilla/mozalloc.h:224 #3 0x7f239b28424d in nsNodeUtils::LastRelease(nsINode*) src/content/base/src/nsNodeUtils.cpp:260 #4 0x7f239b138dfd in nsGenericDOMDataNode::Release() src/content/base/src/nsGenericDOMDataNode.cpp:113 #5 0x7f239b3b00d7 in nsTextNode::Release() src/content/base/src/nsTextNode.cpp:125 #6 0x7f239b3b018b in non-virtual thunk to nsTextNode::Release() src/gfx/cairo/cairo/src/cairo-surface-subsurface.c:0 #7 0x7f2397ba18db in ~nsCOMPtr_base src/../../dist/include/nsCOMPtr.h:408 #8 0x7f2399415899 in nsCOMPtr<nsIDOMNode>::~nsCOMPtr() src/../../../dist/include/nsCOMPtr.h:447 #9 0x7f2399402ab6 in nsCOMPtr<nsIDOMNode>::~nsCOMPtr() src/../../../dist/include/nsCOMPtr.h:447 #10 0x7f239e64ff9d in nsHTMLEditor::IsVisTextNode(nsIContent*, bool*, bool) src/editor/libeditor/html/nsHTMLEditor.cpp:4408 #11 0x7f239e64e47a in nsHTMLEditor::IsTextInDirtyFrameVisible(nsIContent*) src/editor/libeditor/html/nsHTMLEditor.cpp:4348 #12 0x7f239e11704e in nsEditor::IsEditable(nsIContent*) src/editor/libeditor/base/nsEditor.cpp:3742 #13 0x7f239e67039c in nsHTMLEditor::IsEditable(nsIContent*) src/editor/libeditor/html/nsHTMLEditor.cpp:5459 #14 0x7f239e110a91 in nsEditor::FindNode(nsINode*, bool, bool, bool) src/editor/libeditor/base/nsEditor.cpp:3407 #15 0x7f239e10ca79 in nsEditor::GetPriorNode(nsINode*, bool, bool) src/editor/libeditor/base/nsEditor.cpp:3301 #16 0x7f239e10c106 in nsEditor::GetPriorNode(nsINode*, int, bool, bool) src/editor/libeditor/base/nsEditor.cpp:3190 #17 0x7f239e649789 in nsHTMLEditor::GetPriorHTMLNode(nsINode*, int, bool) src/editor/libeditor/html/nsHTMLEditor.cpp:4104 #18 0x7f239e7c3182 in nsHTMLEditRules::GetPromotedPoint(nsHTMLEditRules::RulesEndpoint, nsIDOMNode*, int, EditAction, nsCOMPtr<nsIDOMNode>, int) src/editor/libeditor/html/nsHTMLEditRules.cpp:5277 #19 0x7f239e6d078e in nsHTMLEditRules::PromoteRange(nsIDOMRange*, EditAction) src/editor/libeditor/html/nsHTMLEditRules.cpp:5493 #20 0x7f239e6cac26 in nsHTMLEditRules::AfterEditInner(EditAction, short) src/editor/libeditor/html/nsHTMLEditRules.cpp:430 #21 0x7f239e6c8df6 in nsHTMLEditRules::AfterEdit(EditAction, short) src/editor/libeditor/html/nsHTMLEditRules.cpp:376 #22 0x7f239e63798c in nsHTMLEditor::EndOperation() src/editor/libeditor/html/nsHTMLEditor.cpp:3513 #23 0x7f239e06d372 in ~nsAutoRules src/editor/libeditor/base/nsEditorUtils.h:94 #24 0x7f239e04afc6 in ~nsAutoRules src/editor/libeditor/base/nsEditorUtils.h:91 #25 0x7f239e610e37 in nsHTMLEditor::Align(nsAString_internal const&) src/editor/libeditor/html/nsHTMLEditor.cpp:2264 #26 0x7f239e610fee in non-virtual thunk to nsHTMLEditor::Align(nsAString_internal const&) src/gfx/cairo/cairo/src/cairo-surface-subsurface.c:0 #27 0x7f23a1b430b0 in nsAlignCommand::SetState(nsIEditor*, nsString&) src/editor/composer/src/nsComposerCommands.cpp:970 #28 0x7f23a1b37113 in nsMultiStateCommand::DoCommandParams(char const*, nsICommandParams*, nsISupports*) src/editor/composer/src/nsComposerCommands.cpp:599 #29 0x7f23a13912e2 in nsControllerCommandTable::DoCommandParams(char const*, nsICommandParams*, nsISupports*) src/embedding/components/commandhandler/src/nsControllerCommandTable.cpp:175 previously allocated by thread T0 here: #0 0x4c4bb0 in __interceptor_malloc ??:0 #1 0x7f23b29676da in moz_xmalloc src/memory/mozalloc/mozalloc.cpp:57 #2 0x7f239b3af0d0 in operator new(unsigned long) src/../../../dist/include/mozilla/mozalloc.h:200 #3 0x7f239e412cc7 in nsHtml5TreeOperation::AppendText(unsigned short const*, unsigned int, nsIContent*, nsHtml5TreeOpExecutor*) src/parser/html/nsHtml5TreeOperation.cpp:163 #4 0x7f239e41de8a in nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor*, nsIContent**) src/parser/html/nsHtml5TreeOperation.cpp:444 #5 0x7f239e43ab75 in nsHtml5TreeOpExecutor::RunFlushLoop() src/parser/html/nsHtml5TreeOpExecutor.cpp:564 #6 0x7f239e477259 in nsHtml5ExecutorFlusher::Run() src/parser/html/nsHtml5StreamParser.cpp:127 #7 0x7f23a4db4580 in nsThread::ProcessNextEvent(bool, bool*) src/xpcom/threads/nsThread.cpp:612 #8 0x7f23a4a46ecb in NS_ProcessNextEvent_P(nsIThread*, bool) src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:220 #9 0x7f23a34903b6 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) src/ipc/glue/MessagePump.cpp:82 #10 0x7f23a506ce11 in MessageLoop::RunInternal() src/ipc/chromium/src/base/message_loop.cc:208 #11 0x7f23a506cc46 in MessageLoop::RunHandler() src/ipc/chromium/src/base/message_loop.cc:201 #12 0x7f23a506cb2b in MessageLoop::Run() src/ipc/chromium/src/base/message_loop.cc:175 #13 0x7f23a2937dda in nsBaseAppShell::Run() src/widget/xpwidgets/nsBaseAppShell.cpp:163 #14 0x7f23a156a9b4 in nsAppStartup::Run() src/toolkit/components/startup/nsAppStartup.cpp:290 #15 0x7f2397bdda4d in XREMain::XRE_mainRun() src/toolkit/xre/nsAppRunner.cpp:3782 #16 0x7f2397be38c5 in XREMain::XRE_main(int, char**, nsXREAppData const*) src/toolkit/xre/nsAppRunner.cpp:3848 #17 0x7f2397be6774 in XRE_main src/toolkit/xre/nsAppRunner.cpp:3923 #18 0x40d013 in do_main(int, char**) src/browser/app/nsBrowserApp.cpp:174 #19 0x40a755 in main src/browser/app/nsBrowserApp.cpp:279 #20 0x7f23b5adbc4c in ?? ??:0 Shadow byte and word: 0x1fe46de533b7: fd 0x1fe46de533b0: fd fd fd fd fd fd fd fd More shadow bytes: 0x1fe46de53390: 00 00 00 00 00 00 00 00 0x1fe46de53398: 06 fb fb fb fb fb fb fb 0x1fe46de533a0: fa fa fa fa fa fa fa fa 0x1fe46de533a8: fa fa fa fa fa fa fa fa =>0x1fe46de533b0: fd fd fd fd fd fd fd fd 0x1fe46de533b8: fd fd fd fd fd fd fd fd 0x1fe46de533c0: fa fa fa fa fa fa fa fa 0x1fe46de533c8: fa fa fa fa fa fa fa fa 0x1fe46de533d0: 00 00 00 00 00 00 00 00 Stats: 260M malloced (302M for red zones) by 541116 calls Stats: 44M realloced by 25176 calls Stats: 227M freed by 312858 calls Stats: 92M really freed by 204843 calls Stats: 484M (123992 full pages) mmaped in 121 calls mmaps by size class: 8:311277; 9:32764; 10:12285; 11:14329; 12:3072; 13:1536; 14:1536; 15:256; 16:1024; 17:1248; 18:144; 19:40; 20:20; mallocs by size class: 8:466783; 9:36490; 10:11191; 11:16795; 12:2871; 13:1975; 14:1888; 15:396; 16:1190; 17:1317; 18:159; 19:41; 20:20; frees by size class: 8:255470; 9:27519; 10:7990; 11:13506; 12:2059; 13:1677; 14:1698; 15:352; 16:1127; 17:1300; 18:105; 19:38; 20:17; rfrees by size class: 8:182058; 9:9100; 10:1831; 11:8659; 12:596; 13:527; 14:531; 15:179; 16:934; 17:399; 18:24; 19:4; 20:1; Stats: malloc large: 1537 small slow: 2600 ==10788== 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 23 October 2012 as CVE-2012-4213.

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.