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

Heap-use-after-free in nsTextEditorState::PrepareEditor

Abhishek Arya Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 13 days
  • Paid in 26 days
  • Disclosed after 13 days

Created attachment 674916 Testcase

Reproduces on trunk.

================================================================= ==20748== ERROR: AddressSanitizer heap-use-after-free on address 0x7fec4cb70a60 at pc 0x7fec675d1dda bp 0x7fffdec77c10 sp 0x7fffdec77c08 READ of size 8 at 0x7fec4cb70a60 thread T0 #0 0x7fec675d1dd9 in nsCOMPtr<nsIEditor>::operator=(nsCOMPtr<nsIEditor> const&) ../../../../dist/include/nsCOMPtr.h:614 #1 0x7fec675c7820 in nsTextEditorState::PrepareEditor(nsAString_internal const*) content/html/content/src/nsTextEditorState.cpp:1210 #2 0x7fec675e5be8 in PrepareEditorEvent::Run() content/html/content/src/nsTextEditorState.cpp:1029 #3 0x7fec6623b72c in nsContentUtils::RemoveScriptBlocker() content/base/src/nsContentUtils.cpp:5015 #4 0x7fec646d13de in ~nsAutoScriptBlocker ../../../../dist/include/nsContentUtils.h:2332 #5 0x7fec646bcb26 in ~nsAutoScriptBlocker ../../../../dist/include/nsContentUtils.h:2331 #6 0x7fec64ae1ce2 in PresShell::FlushPendingNotifications(mozFlushType) layout/base/nsPresShell.cpp:3857 #7 0x7fec6522c622 in nsHideViewer::Run() layout/generic/nsSubDocumentFrame.cpp:775 #8 0x7fec6623b72c in nsContentUtils::RemoveScriptBlocker() content/base/src/nsContentUtils.cpp:5015 #9 0x7fec646d13de in ~nsAutoScriptBlocker ../../../../dist/include/nsContentUtils.h:2332 #10 0x7fec646bcb26 in ~nsAutoScriptBlocker ../../../../dist/include/nsContentUtils.h:2331 #11 0x7fec6646a7c2 in nsDocument::AdoptNode(nsIDOMNode*, nsIDOMNode**) content/base/src/nsDocument.cpp:5957 #12 0x7fec6bec6081 in nsIDOMDocument_AdoptNode(JSContext*, unsigned int, JS::Value*) objdir-ff-asan-sym/js/xpconnect/src/dom_quickstubs.cpp:1391 #13 0x7fec77ff04e9 in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) js/src/jscntxtinlines.h:364 #14 0x7fec77fa00e1 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) js/src/jsinterp.cpp:2369 #15 0x7fec77efef8e in js::RunScript(JSContext*, JS::Handle<JSScript*>, js::StackFrame*) js/src/jsinterp.cpp:324 #16 0x7fec77ffdced in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) js/src/jsinterp.cpp:510 #17 0x7fec77fff97b in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) js/src/jsinterp.cpp:547 #18 0x7fec7771447d in JS::Evaluate(JSContext*, JS::Handle<JSObject*>, JS::CompileOptions, unsigned short const*, unsigned long, JS::Value*) js/src/jsapi.cpp:5703 #19 0x7fec689cdf10 in nsJSContext::EvaluateString(nsAString_internal const&, JSObject*, nsIPrincipal*, nsIPrincipal*, char const*, unsigned int, JSVersion, nsAString_internal*, bool*) dom/base/nsJSEnvironment.cpp:1499 #20 0x7fec68b8fb06 in nsGlobalWindow::RunTimeoutHandler(nsTimeout*, nsIScriptContext*) dom/base/nsGlobalWindow.cpp:9740 #21 0x7fec68b43d84 in nsGlobalWindow::RunTimeout(nsTimeout*) dom/base/nsGlobalWindow.cpp:9999 #22 0x7fec68b8d9b8 in nsGlobalWindow::TimerCallback(nsITimer*, void*) dom/base/nsGlobalWindow.cpp:10266 #23 0x7fec70b33762 in nsTimerImpl::Fire() xpcom/threads/nsTimerImpl.cpp:472 #24 0x7fec70b34c6a in nsTimerEvent::Run() xpcom/threads/nsTimerImpl.cpp:555 #25 0x7fec70af70c6 in nsThread::ProcessNextEvent(bool, bool*) xpcom/threads/nsThread.cpp:620 #26 0x7fec7077746b in NS_ProcessNextEvent_P(nsIThread*, bool) objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:220 #27 0x7fec6f04e446 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ipc/glue/MessagePump.cpp:82 #28 0x7fec70dd83e1 in MessageLoop::RunInternal() ipc/chromium/src/base/message_loop.cc:215 #29 0x7fec70dd8216 in MessageLoop::RunHandler() ipc/chromium/src/base/message_loop.cc:208 #30 0x7fec70dd80fb in MessageLoop::Run() ipc/chromium/src/base/message_loop.cc:182 #31 0x7fec6e463c8a in nsBaseAppShell::Run() widget/xpwidgets/nsBaseAppShell.cpp:163 #32 0x7fec6cff4ab4 in nsAppStartup::Run() toolkit/components/startup/nsAppStartup.cpp:290 #33 0x7fec628d83e8 in XREMain::XRE_mainRun() toolkit/xre/nsAppRunner.cpp:3799 #34 0x7fec628de2cb in XREMain::XRE_main(int, char**, nsXREAppData const*) toolkit/xre/nsAppRunner.cpp:3866 #35 0x7fec628e11c4 in XRE_main toolkit/xre/nsAppRunner.cpp:3941 #36 0x40c055 in do_main(int, char**) browser/app/nsBrowserApp.cpp:174 #37 0x409757 in main browser/app/nsBrowserApp.cpp:279 #38 0x7fec81f6376c in ?? ??:0 0x7fec4cb70a60 is located 32 bytes inside of 128-byte region [0x7fec4cb70a40,0x7fec4cb70ac0) freed by thread T0 here: #0 0x4c3d50 in __interceptor_free ??:? #1 0x7fec7fce0406 in moz_free memory/mozalloc/mozalloc.cpp:48 #2 0x7fec6796dc86 in operator delete(void*) ../../../../dist/include/mozilla/mozalloc.h:224 #3 0x7fec6797cf99 in nsHTMLInputElement::HandleTypeChange(unsigned char) content/html/content/src/nsHTMLInputElement.cpp:2628 #4 0x7fec679b1fd4 in nsHTMLInputElement::ParseAttribute(int, nsIAtom*, nsAString_internal const&, nsAttrValue&) content/html/content/src/nsHTMLInputElement.cpp:2758 #5 0x7fec6666d1d9 in nsGenericElement::SetAttr(int, nsIAtom*, nsIAtom*, nsAString_internal const&, bool) content/base/src/nsGenericElement.cpp:1954 #6 0x7fec67538abd in nsGenericHTMLElement::SetAttr(int, nsIAtom*, nsIAtom*, nsAString_internal const&, bool) content/html/content/src/nsGenericHTMLElement.cpp:2002 #7 0x7fec6751c823 in nsGenericHTMLElement::SetAttr(int, nsIAtom*, nsAString_internal const&, bool) content/html/document/src/../../content/src/nsGenericHTMLElement.h:245 #8 0x7fec6751ec27 in nsGenericHTMLElement::SetAttrHelper(nsIAtom*, nsAString_internal const&) content/html/content/src/nsGenericHTMLElement.cpp:2871 #9 0x7fec6798c820 in nsHTMLInputElement::SetType(nsAString_internal const&) content/html/content/src/nsHTMLInputElement.cpp:905 #10 0x7fec6798c982 in non-virtual thunk to nsHTMLInputElement::SetType(nsAString_internal const&) :? #11 0x7fec6c4e71c1 in nsIDOMHTMLInputElement_SetType(JSContext*, JS::Handle<JSObject*>, JS::Handle<long>, int, JS::MutableHandleJS::Value) objdir-ff-asan-sym/js/xpconnect/src/dom_quickstubs.cpp:13483 #12 0x7fec782d5d65 in js::CallJSPropertyOpSetter(JSContext*, int ()(JSContext, JS::Handle<JSObject*>, JS::Handle<long>, int, JS::MutableHandleJS::Value), JS::Handle<JSObject*>, JS::Handle<long>, int, JS::MutableHandleJS::Value) js/src/jscntxtinlines.h:450 #13 0x7fec7830c326 in js::baseops::SetPropertyHelper(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<long>, unsigned int, JS::MutableHandleJS::Value, int) js/src/jsobj.cpp:4613 #14 0x7fec78037376 in js::SetPropertyOperation(JSContext*, unsigned char*, JS::HandleJS::Value, JS::HandleJS::Value) js/src/jsinterpinlines.h:362 previously allocated by thread T0 here: #0 0x4c3e10 in malloc ??:? #1 0x7fec7fce055a in moz_xmalloc memory/mozalloc/mozalloc.cpp:54 #2 0x7fec6796c7aa in operator new(unsigned long) ../../../../dist/include/mozilla/mozalloc.h:200 #3 0x7fec6796b520 in NS_NewHTMLInputElement(already_AddRefed<nsINodeInfo>, mozilla::dom::FromParser) content/html/content/src/nsHTMLInputElement.cpp:538 #4 0x7fec68144d2f in CreateHTMLElement(unsigned int, already_AddRefed<nsINodeInfo>, mozilla::dom::FromParser) content/html/document/src/nsHTMLContentSink.cpp:497 #5 0x7fec6814558a in NS_NewHTMLElement(nsIContent**, already_AddRefed<nsINodeInfo>, mozilla::dom::FromParser) content/html/document/src/nsHTMLContentSink.cpp:480 #6 0x7fec667460f1 in NS_NewElement(nsIContent**, already_AddRefed<nsINodeInfo>, mozilla::dom::FromParser) content/base/src/nsNameSpaceManager.cpp:201 #7 0x7fec69ddd666 in nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor*, nsIContent**) parser/html/nsHtml5TreeOperation.cpp:345 #8 0x7fec69dfe22b in nsHtml5TreeOpExecutor::RunFlushLoop() parser/html/nsHtml5TreeOpExecutor.cpp:564 Shadow byte and word: 0x1ffd8996e14c: fd 0x1ffd8996e148: fd fd fd fd fd fd fd fd More shadow bytes: 0x1ffd8996e128: 00 00 00 00 00 00 00 00 0x1ffd8996e130: 00 00 00 00 00 00 00 00 0x1ffd8996e138: fa fa fa fa fa fa fa fa 0x1ffd8996e140: fa fa fa fa fa fa fa fa =>0x1ffd8996e148: fd fd fd fd fd fd fd fd 0x1ffd8996e150: fd fd fd fd fd fd fd fd 0x1ffd8996e158: fa fa fa fa fa fa fa fa 0x1ffd8996e160: fa fa fa fa fa fa fa fa 0x1ffd8996e168: 00 00 00 00 00 00 00 00 Stats: 239M malloced (227M for red zones) by 420825 calls Stats: 43M realloced by 17471 calls Stats: 201M freed by 199819 calls Stats: 163M really freed by 165412 calls Stats: 248M (63708 full pages) mmaped in 474 calls mmaps by size class: 7:200655; 8:45034; 9:12276; 10:4599; 11:8670; 12:1152; 13:704; 14:544; 15:144; 16:616; 17:452; 18:112; 19:35; 20:21; mallocs by size class: 7:289609; 8:78837; 9:21511; 10:7139; 11:15529; 12:2157; 13:1652; 14:1478; 15:316; 16:1063; 17:1326; 18:146; 19:40; 20:22; frees by size class: 7:111546; 8:49507; 9:15454; 10:4185; 11:12566; 12:1338; 13:1217; 14:1311; 15:263; 16:1015; 17:1310; 18:51; 19:37; 20:19; rfrees by size class: 7:94468; 8:41302; 9:9580; 10:2979; 11:11409; 12:1056; 13:983; 14:1225; 15:217; 16:860; 17:1278; 18:49; 19:5; 20:1; Stats: malloc large: 2913 small slow: 4736 ==20748== 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 November 2012 as CVE-2012-5840.

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.