Skip to content
Memory corruption Disclosed report

Heap-use-after-free in nsHTMLMediaElement::CaptureStreamInternal

Abhishek Arya Follow

Originally disclosed on Mozilla

  • Fixed in 4 months
  • Paid in 5 months
  • Disclosed after 4 months

Reproduces on trunk, testcase coming.

================================================================= ==8572== ERROR: AddressSanitizer heap-use-after-free on address 0x7ff0609a6788 at pc 0x7ff08c1d9180 bp 0x7ffff1561730 sp 0x7ffff1561728 READ of size 8 at 0x7ff0609a6788 thread T0 #0 0x7ff08c1d917f in nsRefPtr<nsDOMMediaStream>::get() const src/../../../../dist/include/nsAutoPtr.h:1003 #1 0x7ff08c2012d1 in nsRefPtr<nsDOMMediaStream>::operator->() const src/../../../../dist/include/nsAutoPtr.h:1023 #2 0x7ff08c20098a in nsHTMLMediaElement::CaptureStreamInternal(bool) src/content/html/content/src/nsHTMLMediaElement.cpp:1536 #3 0x7ff08c202011 in nsHTMLMediaElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream**) src/content/html/content/src/nsHTMLMediaElement.cpp:1550 #4 0x7ff08c1c62f7 in nsHTMLAudioElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream**) src/../../../../dist/include/nsHTMLAudioElement.h:37 #5 0x7ff08c1cf24e in non-virtual thunk to nsHTMLAudioElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream**) src/build/unix/stdc++compat/stdc++compat.cpp:0 #6 0x7ff094299367 in NS_InvokeByIndex_P src/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #7 0x7ff08f8ecbbe in CallMethodHelper::Invoke() src/js/xpconnect/src/XPCWrappedNative.cpp:3118 #8 0x7ff08f94f855 in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) src/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1480 #9 0x7ff09add1ba1 in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) src/js/src/jscntxtinlines.h:389 #10 0x7ff09ad5eab0 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:2413 #11 0x7ff09acc5a55 in js::RunScript(JSContext*, JSScript*, js::StackFrame*) src/js/src/jsinterp.cpp:309 #12 0x7ff09addeeb6 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) src/js/src/jsinterp.cpp:494 #13 0x7ff09c205743 in EvalKernel(JSContext*, JS::CallArgs const&, EvalType, js::StackFrame*, JS::Handle<JSObject*>) src/js/src/builtin/Eval.cpp:284 #14 0x7ff09c206ae2 in js::DirectEval(JSContext*, JS::CallArgs const&) src/js/src/builtin/Eval.cpp:334 #15 0x7ff09c9d9030 in js::mjit::stubs::Eval(js::VMFrame&, unsigned int) src/js/src/methodjit/InvokeHelpers.cpp:393 #16 0x7ff09c37300a in throwpoline_exit src/js/src/methodjit/MethodJIT.cpp:0 #17 0x7ff09c375517 in js::mjit::EnterMethodJIT(JSContext*, js::StackFrame*, void*, JS::Value*, bool) src/js/src/methodjit/MethodJIT.cpp:1016 #18 0x7ff09c3770a0 in CheckStackAndEnterMethodJIT(JSContext*, js::StackFrame*, void*, bool) src/js/src/methodjit/MethodJIT.cpp:1074 #19 0x7ff09c3774f9 in js::mjit::JaegerShotAtSafePoint(JSContext*, void*, bool) src/js/src/methodjit/MethodJIT.cpp:1092 #20 0x7ff09ace5545 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:1472 #21 0x7ff09acc5a55 in js::RunScript(JSContext*, JSScript*, js::StackFrame*) src/js/src/jsinterp.cpp:309 #22 0x7ff09addeeb6 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) src/js/src/jsinterp.cpp:494 #23 0x7ff09ade0e6e in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) src/js/src/jsinterp.cpp:531 #24 0x7ff09a555414 in JS::Evaluate(JSContext*, JS::Handle<JSObject*>, JS::CompileOptions, unsigned short const*, unsigned long, JS::Value*) src/js/src/jsapi.cpp:5710 #25 0x7ff09a55a3b1 in JS_EvaluateUCScriptForPrincipalsVersionOrigin src/js/src/jsapi.cpp:5791 #26 0x7ff08ca9359f in nsJSContext::EvaluateString(nsAString_internal const&, JSObject*, nsIPrincipal*, nsIPrincipal*, char const*, unsigned int, JSVersion, nsAString_internal*, bool*) src/dom/base/nsJSEnvironment.cpp:1494 #27 0x7ff08cc4314f in nsGlobalWindow::RunTimeoutHandler(nsTimeout*, nsIScriptContext*) src/dom/base/nsGlobalWindow.cpp:9624 #28 0x7ff08cbfa8e9 in nsGlobalWindow::RunTimeout(nsTimeout*) src/dom/base/nsGlobalWindow.cpp:9885 #29 0x7ff08cc411aa in nsGlobalWindow::TimerCallback(nsITimer*, void*) src/dom/base/nsGlobalWindow.cpp:10152 #30 0x7ff0941d98d2 in nsTimerImpl::Fire() src/xpcom/threads/nsTimerImpl.cpp:473 #31 0x7ff0941db188 in nsTimerEvent::Run() src/xpcom/threads/nsTimerImpl.cpp:556 #32 0x7ff09419e57e in nsThread::ProcessNextEvent(bool, bool*) src/xpcom/threads/nsThread.cpp:624 #33 0x7ff093e3c927 in NS_ProcessNextEvent_P(nsIThread*, bool) src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:220 #34 0x7ff092dfaad5 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) src/ipc/glue/MessagePump.cpp:82 #35 0x7ff09444b859 in MessageLoop::RunInternal() src/ipc/chromium/src/base/message_loop.cc:208 #36 0x7ff09444b6a2 in MessageLoop::RunHandler() src/ipc/chromium/src/base/message_loop.cc:201 #37 0x7ff09444b587 in MessageLoop::Run() src/ipc/chromium/src/base/message_loop.cc:175 #38 0x7ff0922c7f0e in nsBaseAppShell::Run() src/widget/xpwidgets/nsBaseAppShell.cpp:163 #39 0x7ff090f3f598 in nsAppStartup::Run() src/toolkit/components/startup/nsAppStartup.cpp:273 #40 0x7ff08776bf90 in XREMain::XRE_mainRun() src/toolkit/xre/nsAppRunner.cpp:3800 #41 0x7ff087772204 in XREMain::XRE_main(int, char**, nsXREAppData const*) src/toolkit/xre/nsAppRunner.cpp:3877 #42 0x7ff0877752ce in XRE_main src/toolkit/xre/nsAppRunner.cpp:3953 #43 0x40c5bb in do_main(int, char**) src/browser/app/nsBrowserApp.cpp:174 #44 0x409e1f in main src/browser/app/nsBrowserApp.cpp:279 #45 0x7ff0a4535c4d in ?? ??:0 0x7ff0609a6788 is located 8 bytes inside of 24-byte region [0x7ff0609a6780,0x7ff0609a6798) freed by thread T0 here: #0 0x4c3d80 in free ??:0 #1 0x7ff0a13d3572 in moz_free src/memory/mozalloc/mozalloc.cpp:51 #2 0x7ff08798bac2 in nsTArrayInfallibleAllocator::Free(void*) src/../../dist/include/nsTArray.h:64 #3 0x7ff08798b05c in nsTArray_base<nsTArrayDefaultAllocator>::ShrinkCapacity(unsigned int, unsigned long) src/../../dist/include/nsTArray-inl.h:207 #4 0x7ff087989d2e in nsTArray_base<nsTArrayDefaultAllocator>::ShiftData(unsigned int, unsigned int, unsigned int, unsigned int, unsigned long) src/../../dist/include/nsTArray-inl.h:234 #5 0x7ff08c22fdb9 in nsTArray<nsHTMLMediaElement::OutputMediaStream, nsTArrayDefaultAllocator>::RemoveElementsAt(unsigned int, unsigned int) src/../../../../dist/include/nsTArray.h:934 #6 0x7ff08c1e080e in nsTArray<nsHTMLMediaElement::OutputMediaStream, nsTArrayDefaultAllocator>::Clear() src/../../../../dist/include/nsTArray.h:944 #7 0x7ff08c1e0019 in nsHTMLMediaElement::ShutdownDecoder() src/content/html/content/src/nsHTMLMediaElement.cpp:563 #8 0x7ff08c1e0c16 in nsHTMLMediaElement::AbortExistingLoads() src/content/html/content/src/nsHTMLMediaElement.cpp:579 #9 0x7ff08c1e7a97 in nsHTMLMediaElement::Load() src/content/html/content/src/nsHTMLMediaElement.cpp:709 #10 0x7ff08c1c32d5 in nsHTMLAudioElement::Load() src/../../../../dist/include/nsHTMLAudioElement.h:37 #11 0x7ff08c1ceb8b in non-virtual thunk to nsHTMLAudioElement::Load() src/build/unix/stdc++compat/stdc++compat.cpp:0 #12 0x7ff094299367 in NS_InvokeByIndex_P src/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #13 0x7ff08f8ecbbe in CallMethodHelper::Invoke() src/js/xpconnect/src/XPCWrappedNative.cpp:3118 #14 0x7ff08f94f855 in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) src/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1480 #15 0x7ff09add1ba1 in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) src/js/src/jscntxtinlines.h:389 #16 0x7ff09ad5eab0 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:2413 #17 0x7ff09acc5a55 in js::RunScript(JSContext*, JSScript*, js::StackFrame*) src/js/src/jsinterp.cpp:309 #18 0x7ff09addeeb6 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) src/js/src/jsinterp.cpp:494 #19 0x7ff09c205743 in EvalKernel(JSContext*, JS::CallArgs const&, EvalType, js::StackFrame*, JS::Handle<JSObject*>) src/js/src/builtin/Eval.cpp:284 #20 0x7ff09c206ae2 in js::DirectEval(JSContext*, JS::CallArgs const&) src/js/src/builtin/Eval.cpp:334 #21 0x7ff09c9d9030 in js::mjit::stubs::Eval(js::VMFrame&, unsigned int) src/js/src/methodjit/InvokeHelpers.cpp:393 #22 0x7ff07115d6f4 in
#23 0x7ff09c375517 in js::mjit::EnterMethodJIT(JSContext*, js::StackFrame*, void*, JS::Value*, bool) src/js/src/methodjit/MethodJIT.cpp:1016 #24 0x7ff09c3770a0 in CheckStackAndEnterMethodJIT(JSContext*, js::StackFrame*, void*, bool) src/js/src/methodjit/MethodJIT.cpp:1074 #25 0x7ff09c3769d7 in js::mjit::JaegerShot(JSContext*, bool) src/js/src/methodjit/MethodJIT.cpp:1086 #26 0x7ff09ad633ae in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:2453 #27 0x7ff09acc5a55 in js::RunScript(JSContext*, JSScript*, js::StackFrame*) src/js/src/jsinterp.cpp:309 #28 0x7ff09addeeb6 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) src/js/src/jsinterp.cpp:494 #29 0x7ff09ade0e6f in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) src/js/src/jsinterp.cpp:531 previously allocated by thread T0 here: #0 0x4c3e40 in __interceptor_malloc ??:0 #1 0x7ff0a13d36c6 in moz_xmalloc src/memory/mozalloc/mozalloc.cpp:57 #2 0x7ff087987432 in nsTArrayInfallibleAllocator::Malloc(unsigned long) src/../../dist/include/nsTArray.h:56 #3 0x7ff0879852ed in nsTArray_base<nsTArrayDefaultAllocator>::EnsureCapacity(unsigned int, unsigned int) src/../../dist/include/nsTArray-inl.h:119 #4 0x7ff08c22dab0 in nsTArray<nsHTMLMediaElement::OutputMediaStream, nsTArrayDefaultAllocator>::AppendElements(unsigned int) src/../../../../dist/include/nsTArray.h:891 #5 0x7ff08c200e17 in nsTArray<nsHTMLMediaElement::OutputMediaStream, nsTArrayDefaultAllocator>::AppendElement() src/../../../../dist/include/nsTArray.h:906 #6 0x7ff08c20057f in nsHTMLMediaElement::CaptureStreamInternal(bool) src/content/html/content/src/nsHTMLMediaElement.cpp:1526 #7 0x7ff08c202011 in nsHTMLMediaElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream**) src/content/html/content/src/nsHTMLMediaElement.cpp:1550 #8 0x7ff08c1c62f7 in nsHTMLAudioElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream**) src/../../../../dist/include/nsHTMLAudioElement.h:37 #9 0x7ff08c1cf24e in non-virtual thunk to nsHTMLAudioElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream**) src/build/unix/stdc++compat/stdc++compat.cpp:0 #10 0x7ff094299367 in NS_InvokeByIndex_P src/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #11 0x7ff08f8ecbbe in CallMethodHelper::Invoke() src/js/xpconnect/src/XPCWrappedNative.cpp:3118 #12 0x7ff08f94f855 in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) src/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1480 #13 0x7ff09add1ba1 in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) src/js/src/jscntxtinlines.h:389 #14 0x7ff09ad5eab0 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:2413 #15 0x7ff09acc5a55 in js::RunScript(JSContext*, JSScript*, js::StackFrame*) src/js/src/jsinterp.cpp:309 #16 0x7ff09addeeb6 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) src/js/src/jsinterp.cpp:494 #17 0x7ff09c205743 in EvalKernel(JSContext*, JS::CallArgs const&, EvalType, js::StackFrame*, JS::Handle<JSObject*>) src/js/src/builtin/Eval.cpp:284 #18 0x7ff09c206ae2 in js::DirectEval(JSContext*, JS::CallArgs const&) src/js/src/builtin/Eval.cpp:334 #19 0x7ff09c9d9030 in js::mjit::stubs::Eval(js::VMFrame&, unsigned int) src/js/src/methodjit/InvokeHelpers.cpp:393 #20 0x7ff07115d6f4 in
#21 0x7ff09c375517 in js::mjit::EnterMethodJIT(JSContext*, js::StackFrame*, void*, JS::Value*, bool) src/js/src/methodjit/MethodJIT.cpp:1016 #22 0x7ff09c3770a0 in CheckStackAndEnterMethodJIT(JSContext*, js::StackFrame*, void*, bool) src/js/src/methodjit/MethodJIT.cpp:1074 #23 0x7ff09c3774f9 in js::mjit::JaegerShotAtSafePoint(JSContext*, void*, bool) src/js/src/methodjit/MethodJIT.cpp:1092 #24 0x7ff09ace5546 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:1472 Shadow byte and word: 0x1ffe0c134cf1: fd 0x1ffe0c134cf0: fd fd fd fd fd fd fd fd More shadow bytes: 0x1ffe0c134cd0: fd fd fd fd fd fd fd fd 0x1ffe0c134cd8: fd fd fd fd fd fd fd fd 0x1ffe0c134ce0: fa fa fa fa fa fa fa fa 0x1ffe0c134ce8: fa fa fa fa fa fa fa fa =>0x1ffe0c134cf0: fd fd fd fd fd fd fd fd 0x1ffe0c134cf8: fd fd fd fd fd fd fd fd 0x1ffe0c134d00: fa fa fa fa fa fa fa fa 0x1ffe0c134d08: fa fa fa fa fa fa fa fa 0x1ffe0c134d10: 00 00 00 00 fb fb fb fb Stats: 274M malloced (291M for red zones) by 467459 calls Stats: 41M realloced by 26550 calls Stats: 232M freed by 312131 calls Stats: 97M really freed by 181036 calls Stats: 456M (116819 full pages) mmaped in 114 calls mmaps by size class: 8:245745; 9:40955; 10:16380; 11:14329; 12:4096; 13:2560; 14:1280; 15:256; 16:448; 17:1248; 18:192; 19:40; 20:16; mallocs by size class: 8:354761; 9:59447; 10:21309; 11:20690; 12:3786; 13:2988; 14:1730; 15:408; 16:579; 17:1498; 18:206; 19:41; 20:16; frees by size class: 8:220589; 9:48134; 10:17220; 11:17141; 12:2688; 13:2372; 14:1476; 15:365; 16:497; 17:1484; 18:114; 19:39; 20:12; rfrees by size class: 8:134988; 9:23860; 10:9148; 11:9537; 12:864; 13:718; 14:742; 15:165; 16:345; 17:642; 18:22; 19:4; 20:1; Stats: malloc large: 1761 small slow: 2415 ==8572== ABORTING

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

What is known

A high-severity memory corruption bug in Audio/Video. Mozilla made it public on 21 December 2012.

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

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

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 Abhishek Arya

View all

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