Use-after-free of AudioSink::NotifyAudioNeeded
A heap-use-after-free occurs in Firefox's audio sink code when a media element's audio sink is freed while a queued audio callback still references it. An attacker could trigger a browser crash by loading a crafted page, though the report only demonstrates a crash under AddressSanitizer.
- Fixed in 21 days
- Paid in 29 days
- Disclosed after 21 days
Created attachment 9255182 poc.html
Tested Version: Ubuntu 64-bit memory 8G + linux64-fuzzing-asan-opt(95.0.1 (64-bit)) => linux64-fuzzing-asan-opt
Loading poc.html into the firefox browser to create a new tab(Using the grizzly tool(allow pop-ups)),This poc is not 100% stable, and I can only trigger it in the docker container,if it fails, please repeat more times. the crash report is as follows:
================================================================= ==40332==ERROR: AddressSanitizer: heap-use-after-free on address 0x6180000503f8 at pc 0x7f9161f84be0 bp 0x7f913ee81570 sp 0x7f913ee81568 READ of size 8 at 0x6180000503f8 thread T33 (MediaDe~hine #1) #0 0x7f9161f84bdf in mozilla::AudioSink::NotifyAudioNeeded() /builds/worker/checkouts/gecko/dom/media/mediasink/AudioSink.cpp:361:10 #1 0x7f9161fa63af in operator() /builds/worker/workspace/obj-build/dist/include/MediaEventSource.h:404:7 #2 0x7f9161fa63af in ApplyWithArgsImpl<(lambda at /builds/worker/workspace/obj-build/dist/include/MediaEventSource.h:403:37)> /builds/worker/workspace/obj-build/dist/include/MediaEventSource.h:214:5 #3 0x7f9161fa63af in mozilla::detail::ListenerImpl<mozilla::AbstractThread, std::enable_if<TakeArgs<void (mozilla::AudioSink::)(RefPtrmozilla::AudioData const&)>::value, mozilla::MediaEventListener>::type mozilla::MediaEventSourceImpl<(mozilla::ListenerPolicy)1, RefPtrmozilla::AudioData >::ConnectInternal<mozilla::AbstractThread, mozilla::AudioSink, void (mozilla::AudioSink::)(RefPtrmozilla::AudioData const&)>(mozilla::AbstractThread*, mozilla::AudioSink*, void (mozilla::AudioSink::)(RefPtrmozilla::AudioData const&))::'lambda'(RefPtrmozilla::AudioData&&), RefPtrmozilla::AudioData >::ApplyWithArgs(RefPtrmozilla::AudioData&&) /builds/worker/workspace/obj-build/dist/include/MediaEventSource.h:236:5 #4 0x7f9161b8caee in applyImpl<mozilla::detail::Listener<RefPtrmozilla::AudioData >, void (mozilla::detail::Listener<RefPtrmozilla::AudioData >::)(RefPtrmozilla::AudioData &&), StoreCopyPassByRRef<RefPtrmozilla::AudioData > , 0UL> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1147:12 #5 0x7f9161b8caee in apply<mozilla::detail::Listener<RefPtrmozilla::AudioData >, void (mozilla::detail::Listener<RefPtrmozilla::AudioData >::)(RefPtrmozilla::AudioData &&)> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1153:12 #6 0x7f9161b8caee in mozilla::detail::RunnableMethodImpl<mozilla::detail::Listener<RefPtrmozilla::AudioData >, void (mozilla::detail::Listener<RefPtrmozilla::AudioData >::)(RefPtrmozilla::AudioData&&), true, (mozilla::RunnableKind)0, RefPtrmozilla::AudioData&&>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1200:13 #7 0x7f915ba95b70 in mozilla::AutoTaskDispatcher::TaskGroupRunnable::Run() /builds/worker/workspace/obj-build/dist/include/mozilla/TaskDispatcher.h:227:35 #8 0x7f915baa2f0d in mozilla::TaskQueue::Runner::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskQueue.cpp:208:20 #9 0x7f915bacac3b in nsThreadPool::Run() /builds/worker/checkouts/gecko/xpcom/threads/nsThreadPool.cpp:305:14 #10 0x7f915babd9f4 in nsThread::ProcessNextEvent(bool, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1169:16 #11 0x7f915bac76ec in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:467:10 #12 0x7f915cf4ee0d in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:300:20 #13 0x7f915cdd91f1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:331:10 #14 0x7f915cdd91f1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:324:3 #15 0x7f915cdd91f1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:306:3 #16 0x7f915bab6d7b in nsThread::ThreadFunc(void*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:391:10 #17 0x7f917722a09e in _pt_root /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:201:5 #18 0x7f9178b50608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x9608) #19 0x7f9178718292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
0x6180000503f8 is located 888 bytes inside of 896-byte region [0x618000050080,0x618000050400) freed by thread T33 (MediaDe~hine #1) here: #0 0x563dfcba4cb2 in __interceptor_free /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:111:3 #1 0x7f9161f88e9e in operator() /builds/worker/workspace/obj-build/dist/include/mozilla/UniquePtr.h:463:5 #2 0x7f9161f88e9e in reset /builds/worker/workspace/obj-build/dist/include/mozilla/UniquePtr.h:305:7 #3 0x7f9161f88e9e in ~UniquePtr /builds/worker/workspace/obj-build/dist/include/mozilla/UniquePtr.h:253:18 #4 0x7f9161f88e9e in mozilla::AudioSinkWrapper::~AudioSinkWrapper() /builds/worker/checkouts/gecko/dom/media/mediasink/AudioSinkWrapper.cpp:17:37 #5 0x7f9161f88fdd in mozilla::AudioSinkWrapper::~AudioSinkWrapper() /builds/worker/checkouts/gecko/dom/media/mediasink/AudioSinkWrapper.cpp:17:37 #6 0x7f915c92d09f in mozilla::MozPromise<bool, nsresult, false>::ThenValueBase::ResolveOrRejectRunnable::Run() /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:487:21 #7 0x7f915ba95b70 in mozilla::AutoTaskDispatcher::TaskGroupRunnable::Run() /builds/worker/workspace/obj-build/dist/include/mozilla/TaskDispatcher.h:227:35 #8 0x7f915baa2f0d in mozilla::TaskQueue::Runner::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskQueue.cpp:208:20 #9 0x7f915bacac3b in nsThreadPool::Run() /builds/worker/checkouts/gecko/xpcom/threads/nsThreadPool.cpp:305:14 #10 0x7f915babd9f4 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1169:16 #11 0x7f915bac76ec in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:467:10 #12 0x7f915cf4ee0d in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:300:20 #13 0x7f915cdd91f1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:331:10 #14 0x7f915cdd91f1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:324:3 #15 0x7f915cdd91f1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:306:3 #16 0x7f915bab6d7b in nsThread::ThreadFunc(void*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:391:10 #17 0x7f917722a09e in _pt_root /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:201:5 #18 0x7f9178b50608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x9608)
previously allocated by thread T33 (MediaDe~hine #1) here: #0 0x563dfcba4f1d in __interceptor_malloc /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:129:3 #1 0x563dfcbdfb8d in moz_xmalloc /builds/worker/checkouts/gecko/memory/mozalloc/mozalloc.cpp:52:15 #2 0x7f9161bc2a7d in operator new /builds/worker/workspace/obj-build/dist/include/mozilla/cxxalloc.h:33:10 #3 0x7f9161bc2a7d in operator() /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp:2871:9 #4 0x7f9161bc2a7d in mozilla::AudioSinkWrapper::CreatorImplmozilla::MediaDecoderStateMachine::CreateAudioSink()::$_31::Create(mozilla::media::TimeUnit const&) /builds/worker/checkouts/gecko/dom/media/mediasink/AudioSinkWrapper.h:42:14 #5 0x7f9161f89bd2 in mozilla::AudioSinkWrapper::Start(mozilla::media::TimeUnit const&, mozilla::MediaInfo const&) /builds/worker/checkouts/gecko/dom/media/mediasink/AudioSinkWrapper.cpp:174:30 #6 0x7f9161f9b01f in mozilla::VideoSink::Start(mozilla::media::TimeUnit const&, mozilla::MediaInfo const&) /builds/worker/checkouts/gecko/dom/media/mediasink/VideoSink.cpp:219:29 #7 0x7f9161a322be in mozilla::MediaDecoderStateMachine::StartMediaSink() /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp:3460:29 #8 0x7f9161a1c504 in mozilla::MediaDecoderStateMachine::MaybeStartPlayback() /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp:3052:3 #9 0x7f9161a3a864 in mozilla::MediaDecoderStateMachine::ResumeMediaSink() /builds/worker/checkouts/gecko/dom/media/MediaDecoderStateMachine.cpp:3930:3 #10 0x7f9161bdcedd in applyImpl<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine::)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1147:12 #11 0x7f9161bdcedd in apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine::)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1153:12 #12 0x7f9161bdcedd in mozilla::detail::RunnableMethodImpl<mozilla::MediaDecoderStateMachine*, void (mozilla::MediaDecoderStateMachine::)(), true, (mozilla::RunnableKind)0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1200:13 #13 0x7f915ba95b70 in mozilla::AutoTaskDispatcher::TaskGroupRunnable::Run() /builds/worker/workspace/obj-build/dist/include/mozilla/TaskDispatcher.h:227:35 #14 0x7f915baa2f0d in mozilla::TaskQueue::Runner::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskQueue.cpp:208:20 #15 0x7f915bacac3b in nsThreadPool::Run() /builds/worker/checkouts/gecko/xpcom/threads/nsThreadPool.cpp:305:14 #16 0x7f915babd9f4 in nsThread::ProcessNextEvent(bool, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1169:16 #17 0x7f915bac76ec in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:467:10 #18 0x7f915cf4ee0d in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:300:20 #19 0x7f915cdd91f1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:331:10 #20 0x7f915cdd91f1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:324:3 #21 0x7f915cdd91f1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:306:3 #22 0x7f915bab6d7b in nsThread::ThreadFunc(void*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:391:10 #23 0x7f917722a09e in _pt_root /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:201:5 #24 0x7f9178b50608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x9608)
Thread T33 (MediaDe~hine #1) created by T0 (Web Content) here: #0 0x563dfcb8f61c in __interceptor_pthread_create /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cpp:207:3 #1 0x7f917721a124 in _PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:458:14 #2 0x7f917720b3ce in PR_CreateThread /builds/worker/checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:533:12 #3 0x7f915bab9bcd in nsThread::Init(nsTSubstring<char> const&) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:607:18 #4 0x7f915bac59cf in nsThreadManager::NewNamedThread(nsTSubstring<char> const&, unsigned int, nsIThread**) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadManager.cpp:581:12 #5 0x7f915bacfc31 in NS_NewNamedThread(nsTSubstring<char> const&, nsIThread**, already_AddRefed<nsIRunnable>, unsigned int) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:163:57 #6 0x7f915bac9859 in NS_NewNamedThread /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:155:10 #7 0x7f915bac9859 in nsThreadPool::PutEvent(already_AddRefed<nsIRunnable>, unsigned int) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadPool.cpp:120:17 #8 0x7f915bacbae9 in nsThreadPool::Dispatch(already_AddRefed<nsIRunnable>, unsigned int) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadPool.cpp:357:5 #9 0x7f915baa0d23 in mozilla::TaskQueue::DispatchLocked(nsCOMPtr<nsIRunnable>&, unsigned int, mozilla::AbstractThread::DispatchReason) /builds/worker/checkouts/gecko/xpcom/threads/TaskQueue.cpp:68:26 #10 0x7f915bad3933 in mozilla::TaskQueue::Dispatch(already_AddRefed<nsIRunnable>, mozilla::AbstractThread::DispatchReason) /builds/worker/workspace/obj-build/dist/include/mozilla/TaskQueue.h:87:14 #11 0x7f915ba95755 in mozilla::AutoTaskDispatcher::DispatchTaskGroup(mozilla::UniquePtr<mozilla::AutoTaskDispatcher::PerThreadTaskGroup, mozilla::DefaultDeletemozilla::AutoTaskDispatcher::PerThreadTaskGroup >) /builds/worker/workspace/obj-build/dist/include/mozilla/TaskDispatcher.h:275:20 #12 0x7f915ba94b36 in mozilla::AutoTaskDispatcher::~AutoTaskDispatcher() /builds/worker/workspace/obj-build/dist/include/mozilla/TaskDispatcher.h:121:7 #13 0x7f915ba96ad9 in reset /builds/worker/workspace/obj-build/dist/include/mozilla/Maybe.h:639:19 #14 0x7f915ba96ad9 in mozilla::XPCOMThreadWrapper::MaybeFireTailDispatcher() /builds/worker/checkouts/gecko/xpcom/threads/AbstractThread.cpp:195:23 #15 0x7f915ba92fac in AfterProcessNextEvent /builds/worker/checkouts/gecko/xpcom/threads/AbstractThread.cpp:133:5 #16 0x7f915ba92fac in non-virtual thunk to mozilla::XPCOMThreadWrapper::AfterProcessNextEvent(nsIThreadInternal*, bool) /builds/worker/checkouts/gecko/xpcom/threads/AbstractThread.cpp #17 0x7f915babd537 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1199:3 #18 0x7f915bac76ec in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:467:10 #19 0x7f915cf4d84f in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21 #20 0x7f915cdd91f1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:331:10 #21 0x7f915cdd91f1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:324:3 #22 0x7f915cdd91f1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:306:3 #23 0x7f91635d3567 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:137:27 #24 0x7f916772a5df in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:917:20 #25 0x7f915cdd91f1 in RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:331:10 #26 0x7f915cdd91f1 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:324:3 #27 0x7f915cdd91f1 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:306:3 #28 0x7f9167729851 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:749:34 #29 0x563dfcbd987d in content_process_main(mozilla::Bootstrap*, int, char**) /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28 #30 0x563dfcbd9ca8 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:327:18 #31 0x7f917861d0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/checkouts/gecko/dom/media/mediasink/AudioSink.cpp:361:10 in mozilla::AudioSink::NotifyAudioNeeded() Shadow bytes around the buggy address: 0x0c3080002020: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3080002030: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3080002040: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3080002050: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3080002060: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd =>0x0c3080002070: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd[fd] 0x0c3080002080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c3080002090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c30800020a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c30800020b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c30800020c0: 00 00 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 ==40332==ABORTING
This vuln is discovered by bo13oy of Cyber Kunlun Lab.
Thanks.
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 a race where the AudioSinkWrapper is destroyed (freeing the AudioSink) while a queued MediaEventSource callback still invokes AudioSink::NotifyAudioNeeded on the freed object.
Impact
A crafted page could crash the browser's media process; the report does not demonstrate code execution, and the crash was only reproducible in a specific containerised ASan build.
What the attacker needed
Victim loads a crafted HTML page; pop-ups allowed; specific ASan build and container
How it was found
- Open the provided proof-of-concept HTML file in Firefox, allowing pop-ups, so a new tab is created.
- Repeat loading the page several times because the crash is not reliably reproducible.
- Observe the AddressSanitizer heap-use-after-free crash in AudioSink::NotifyAudioNeeded.
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.
When a browser plays audio or video, it creates an object that manages the sound output. A use-after-free means the program frees that object but later still tries to read from it, which can crash the browser or, in worse cases, let an attacker run code. Here the crash happens in a background media thread while handling audio 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.