Skip to content
Memory corruption Disclosed report CVE-2014-1538

Heap-use-after-free in nsTextEditRules::CreateMozBR

Abhishek Arya Follow

Originally disclosed on Mozilla

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

Created attachment 8416988 Testcase

Install fuzzPriv extension before running test.html

==16549==ERROR: AddressSanitizer: heap-use-after-free on address 0x6190009a83a0 at pc 0x7f2757bcb74a bp 0x7fff5c52fb50 sp 0x7fff5c52fb48 READ of size 8 at 0x6190009a83a0 thread T0 #0 0x7f2757bcb749 in nsTextEditRules::CreateMozBR(nsIDOMNode*, int, nsIDOMNode**) editor/libeditor/text/nsTextEditRules.cpp:1347 #1 0x7f2757c65f33 in nsHTMLEditRules::InsertMozBRIfNeeded(nsIDOMNode*) editor/libeditor/html/nsHTMLEditRules.cpp:8607 #2 0x7f2757c38455 in nsHTMLEditRules::DidDoAction(nsISelection*, nsRulesInfo*, tag_nsresult) editor/libeditor/html/nsHTMLEditRules.cpp:3648 #3 0x7f2757c9627c in nsHTMLEditor::InsertBasicBlock(nsAString_internal const&) editor/libeditor/html/nsHTMLEditor.cpp:2165 #4 0x7f2757c94b5f in nsHTMLEditor::SetParagraphFormat(nsAString_internal const&) editor/libeditor/html/nsHTMLEditor.cpp:1725 #5 0x7f2756434871 in nsParagraphStateCommand::SetState(nsIEditor*, nsString&) editor/composer/src/nsComposerCommands.cpp:654 #6 0x7f2756433d8e in nsMultiStateCommand::DoCommandParams(char const*, nsICommandParams*, nsISupports*) editor/composer/src/nsComposerCommands.cpp:599 #7 0x7f2758cebd3f in nsControllerCommandTable::DoCommandParams(char const*, nsICommandParams*, nsISupports*) embedding/components/commandhandler/src/nsControllerCommandTable.cpp:171 #8 0x7f2758ce20aa in non-virtual thunk to nsBaseCommandController::DoCommandWithParams(char const*, nsICommandParams*) embedding/components/commandhandler/src/nsBaseCommandController.cpp:152 #9 0x7f2758ce8026 in nsCommandManager::DoCommand(char const*, nsICommandParams*, nsIDOMWindow*) embedding/components/commandhandler/src/nsCommandManager.cpp:233 #10 0x7f275761d2f0 in nsHTMLDocument::ExecCommand(nsAString_internal const&, bool, nsAString_internal const&, mozilla::ErrorResult&) content/html/document/src/nsHTMLDocument.cpp:3242 #11 0x7f275574160f in mozilla::dom::HTMLDocumentBinding::execCommand(JSContext*, JS::Handle<JSObject*>, nsHTMLDocument*, JSJitMethodCallArgs const&) objdir-ff-asan/dom/bindings/./HTMLDocumentBinding.cpp:802 #12 0x7f27561a4ae7 in mozilla::dom::GenericBindingMethod(JSContext*, unsigned int, JS::Value*) dom/bindings/BindingUtils.cpp:2300 #13 0x7f275ae8fea0 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/jscntxtinlines.h:239 #14 0x7f275ae83cc8 in Interpret(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:2620 #15 0x7f275ae67599 in js::RunScript(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:422 #16 0x7f275ae92dcb in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::AbstractFramePtr, JS::Value*) js/src/vm/Interpreter.cpp:630 #17 0x7f275ae9336e in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) js/src/vm/Interpreter.cpp:666 #18 0x7f275aae699b in Evaluate(JSContext*, JS::Handle<JSObject*>, JS::ReadOnlyCompileOptions const&, JS::SourceBufferHolder&, JS::Value*) js/src/jsapi.cpp:4984 #19 0x7f275691e0d0 in nsJSUtils::EvaluateString(JSContext*, JS::SourceBufferHolder&, JS::Handle<JSObject*>, JS::CompileOptions&, nsJSUtils::EvaluateOptions const&, JS::MutableHandleJS::Value, void**) dom/base/nsJSUtils.cpp:254 #20 0x7f275691d6ea in nsJSUtils::EvaluateString(JSContext*, nsAString_internal const&, JS::Handle<JSObject*>, JS::CompileOptions&, nsJSUtils::EvaluateOptions const&, JS::MutableHandleJS::Value, void**) dom/base/nsJSUtils.cpp:186 #21 0x7f275691ed00 in nsJSUtils::EvaluateString(JSContext*, nsAString_internal const&, JS::Handle<JSObject*>, JS::CompileOptions&, void**) dom/base/nsJSUtils.cpp:306 #22 0x7f27567fccb5 in nsGlobalWindow::RunTimeoutHandler(nsTimeout*, nsIScriptContext*) dom/base/nsGlobalWindow.cpp:11936 #23 0x7f27567da69c in nsGlobalWindow::RunTimeout(nsTimeout*) dom/base/nsGlobalWindow.cpp:12166 #24 0x7f27567fbd91 in nsGlobalWindow::TimerCallback(nsITimer*, void*) dom/base/nsGlobalWindow.cpp:12412 #25 0x7f27539860d4 in nsTimerImpl::Fire() xpcom/threads/nsTimerImpl.cpp:555 #26 0x7f275398675e in nsTimerEvent::Run() xpcom/threads/nsTimerImpl.cpp:639 #27 0x7f275397d7e0 in nsThread::ProcessNextEvent(bool, bool*) xpcom/threads/nsThread.cpp:715 #28 0x7f275383db1a in NS_ProcessNextEvent(nsIThread*, bool) xpcom/glue/nsThreadUtils.cpp:263 #29 0x7f2754165f98 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ipc/glue/MessagePump.cpp:136 #30 0x7f275410e5f0 in MessageLoop::Run() ipc/chromium/src/base/message_loop.cc:229 #31 0x7f27563e0007 in nsBaseAppShell::Run() widget/xpwidgets/nsBaseAppShell.cpp:164 #32 0x7f275925c5f8 in nsAppStartup::Run() toolkit/components/startup/nsAppStartup.cpp:278 #33 0x7f27590d81a3 in XREMain::XRE_mainRun() toolkit/xre/nsAppRunner.cpp:4019 #34 0x7f27590d9085 in XREMain::XRE_main(int, char**, nsXREAppData const*) toolkit/xre/nsAppRunner.cpp:4088 #35 0x7f27590d9edd in XRE_main toolkit/xre/nsAppRunner.cpp:4300 #36 0x48c6e7 in main browser/app/nsBrowserApp.cpp:282 #37 0x7f27621ae76c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 #38 0x48bbbc in _start

0x6190009a83a0 is located 32 bytes inside of 1104-byte region [0x6190009a8380,0x6190009a87d0) freed by thread T0 here: #0 0x473b81 in __interceptor_free asan_rtl #1 0x7f275388f10a in SnowWhiteKiller::~SnowWhiteKiller() xpcom/base/nsCycleCollector.cpp:2403 #2 0x7f275388ed19 in nsCycleCollector::FreeSnowWhite(bool) xpcom/base/nsCycleCollector.cpp:2569 #3 0x7f2753894be1 in nsCycleCollector::BeginCollection(ccType, nsICycleCollectorListener*) xpcom/base/nsCycleCollector.cpp:3445 #4 0x7f27538942e6 in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*) xpcom/base/nsCycleCollector.cpp:3307 #5 0x7f2753897ea3 in nsCycleCollector_collect(nsICycleCollectorListener*) xpcom/base/nsCycleCollector.cpp:3860 #6 0x7f275684c5a6 in nsJSContext::CycleCollectNow(nsICycleCollectorListener*, int) dom/base/nsJSEnvironment.cpp:1940 #7 0x7f2756756408 in nsDOMWindowUtils::CycleCollect(nsICycleCollectorListener*, int) dom/base/nsDOMWindowUtils.cpp:1485 #8 0x7f27539909e1 in NS_InvokeByIndex xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #9 0x7f2756580977 in XPCWrappedNative::CallMethod(XPCCallContext&, XPCWrappedNative::CallMode) js/xpconnect/src/XPCWrappedNative.cpp:2399 #10 0x7f27565865fe in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1277 #11 0x7f275ae8fea0 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/jscntxtinlines.h:239 #12 0x7f275ae83cc8 in Interpret(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:2620 #13 0x7f275ae67599 in js::RunScript(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:422 #14 0x7f275ae903ee in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/vm/Interpreter.cpp:494 #15 0x7f275ae9149e in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandleJS::Value) js/src/vm/Interpreter.cpp:531 #16 0x7f275ac74f24 in js::DirectProxyHandler::call(JSContext*, JS::Handle<JSObject*>, JS::CallArgs const&) js/src/jsproxy.cpp:448 #17 0x7f275ad7a6f6 in js::CrossCompartmentWrapper::call(JSContext*, JS::Handle<JSObject*>, JS::CallArgs const&) js/src/jswrapper.cpp:464 #18 0x7f275ac97da5 in js::Proxy::call(JSContext*, JS::Handle<JSObject*>, JS::CallArgs const&) js/src/jsproxy.cpp:2659 #19 0x7f275ac9d2c4 in js::proxy_Call(JSContext*, unsigned int, JS::Value*) js/src/jsproxy.cpp:3062 #20 0x7f275ae8fea0 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/jscntxtinlines.h:239 #21 0x7f275ae83cc8 in Interpret(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:2620 #22 0x7f275ae67599 in js::RunScript(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:422 #23 0x7f275ae903ee in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/vm/Interpreter.cpp:494 #24 0x7f275ae9149e in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandleJS::Value) js/src/vm/Interpreter.cpp:531 #25 0x7f275aae9aaf in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) js/src/jsapi.cpp:5196 #26 0x7f275561872a in mozilla::dom::EventListener::HandleEvent(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, mozilla::ErrorResult&) objdir-ff-asan/dom/bindings/./EventListenerBinding.cpp:43 #27 0x7f2756a46c8a in void mozilla::dom::EventListener::HandleEventmozilla::dom::EventTarget*(mozilla::dom::EventTarget* const&, mozilla::dom::Event&, mozilla::ErrorResult&, mozilla::dom::CallbackObject::ExceptionHandling) objdir-ff-asan/dom/events/../../dist/include/mozilla/dom/EventListenerBinding.h:53 #28 0x7f2756a464e8 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) dom/events/EventListenerManager.cpp:946 #29 0x7f2756a478a0 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) dom/events/EventListenerManager.cpp:1011

previously allocated by thread T0 here: #0 0x473d81 in malloc asan_rtl #1 0x7f275e324a4d in moz_xmalloc memory/mozalloc/mozalloc.cpp:52 #2 0x7f2757c8907d in nsHTMLEditor::InitRules() objdir-ff-asan/editor/libeditor/html/../../../dist/include/mozilla/mozalloc.h:201 #3 0x7f2757bcbf3a in nsAutoEditInitRulesTrigger::~nsAutoEditInitRulesTrigger() editor/libeditor/text/nsPlaintextEditor.cpp:208 #4 0x7f2757c86fdc in nsHTMLEditor::Init(nsIDOMDocument*, nsIContent*, nsISelectionController*, unsigned int, nsAString_internal const&) editor/libeditor/html/nsHTMLEditor.cpp:299 #5 0x7f275644be09 in nsEditingSession::SetupEditorOnWindow(nsIDOMWindow*) editor/composer/src/nsEditingSession.cpp:450 #6 0x7f275644904f in nsEditingSession::MakeWindowEditable(nsIDOMWindow*, char const*, bool, bool, bool) editor/composer/src/nsEditingSession.cpp:168 #7 0x7f27576074b9 in nsHTMLDocument::EditingStateChanged() content/html/document/src/nsHTMLDocument.cpp:2734 #8 0x7f275761baf5 in nsHTMLDocument::SetDesignMode(nsAString_internal const&, mozilla::ErrorResult&) content/html/document/src/nsHTMLDocument.cpp:2877 #9 0x7f275573b791 in mozilla::dom::HTMLDocumentBinding::set_designMode(JSContext*, JS::Handle<JSObject*>, nsHTMLDocument*, JSJitSetterCallArgs) objdir-ff-asan/dom/bindings/./HTMLDocumentBinding.cpp:734 #10 0x7f27561a43a5 in mozilla::dom::GenericBindingSetter(JSContext*, unsigned int, JS::Value*) dom/bindings/BindingUtils.cpp:2269 #11 0x7f275ae8fea0 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/jscntxtinlines.h:239 #12 0x7f275ae9149e in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandleJS::Value) js/src/vm/Interpreter.cpp:531 #13 0x7f275ae9283d in js::InvokeGetterOrSetter(JSContext*, JSObject*, JS::Value, unsigned int, JS::Value*, JS::MutableHandleJS::Value) js/src/vm/Interpreter.cpp:603 #14 0x7f275ac71cce in js::BaseProxyHandler::set(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<jsid>, bool, JS::MutableHandleJS::Value) js/src/jscntxtinlines.h:342 #15 0x7f27561a9c8b in mozilla::dom::DOMProxyHandler::set(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<jsid>, bool, JS::MutableHandleJS::Value) dom/bindings/DOMJSProxyHandler.cpp:228 #16 0x7f275ac96b49 in js::Proxy::set(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<jsid>, bool, JS::MutableHandleJS::Value) js/src/jsproxy.cpp:2572 #17 0x7f275ac0fa4e in JSObject::nonNativeSetProperty(JSContext*, JS::Handle<JSObject*>, JS::Handle<jsid>, JS::MutableHandleJS::Value, bool) js/src/jsobj.cpp:1668 #18 0x7f275ae81125 in Interpret(JSContext*, js::RunState&) js/src/jsobj.h:1022 #19 0x7f275ae67599 in js::RunScript(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:422 #20 0x7f275ae903ee in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/vm/Interpreter.cpp:494 #21 0x7f275ae9149e in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandleJS::Value) js/src/vm/Interpreter.cpp:531 #22 0x7f275aae9aaf in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) js/src/jsapi.cpp:5196 #23 0x7f275561872a in mozilla::dom::EventListener::HandleEvent(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, mozilla::ErrorResult&) objdir-ff-asan/dom/bindings/./EventListenerBinding.cpp:43 #24 0x7f2756a46c8a in void mozilla::dom::EventListener::HandleEventmozilla::dom::EventTarget*(mozilla::dom::EventTarget* const&, mozilla::dom::Event&, mozilla::ErrorResult&, mozilla::dom::CallbackObject::ExceptionHandling) objdir-ff-asan/dom/events/../../dist/include/mozilla/dom/EventListenerBinding.h:53 #25 0x7f2756a464e8 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) dom/events/EventListenerManager.cpp:946 #26 0x7f2756a478a0 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) dom/events/EventListenerManager.cpp:1011 #27 0x7f2756a382b1 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) dom/events/EventDispatcher.cpp:287 #28 0x7f2756a3c3d6 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsCOMArraymozilla::dom::EventTarget) dom/events/EventDispatcher.cpp:597 #29 0x7f2756a023f5 in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports, mozilla::WidgetEvent*, nsIDOMEvent*, nsPresContext*, nsEventStatus*) dom/events/EventDispatcher.cpp:661

SUMMARY: AddressSanitizer: heap-use-after-free ??:0 ?? Shadow bytes around the buggy address: 0x0c328012d020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c328012d030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c328012d040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c328012d050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c328012d060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0c328012d070: fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd 0x0c328012d080: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c328012d090: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c328012d0a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c328012d0b0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c328012d0c0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Heap right redzone: fb Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack partial redzone: f4 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Contiguous container OOB:fc ASan internal: fe ==16549==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 17 May 2014 as CVE-2014-1538.

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.