Skip to content
Memory corruption Disclosed report

Heap-use-after-free in mozilla::dom::CropDataSourceSurface

Abhishek Arya Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 16 days
  • Paid in 5 months
  • Disclosed after 16 days

Created attachment 8642198 canvas.html

================================================================= ==29983==ERROR: AddressSanitizer: heap-use-after-free on address 0x61b0000c7480 at pc 0x0000004a0b28 bp 0x7ffd442c4bd0 sp 0x7ffd442c4380 READ of size 120 at 0x61b0000c7480 thread T0 (Web Content) #0 0x4a0b27 in __asan_memcpy asan_rtl #1 0x7fd9a0fcf33d in mozilla::dom::CropDataSourceSurface(mozilla::gfx::DataSourceSurface*, mozilla::gfx::IntRectTypedmozilla::gfx::UnknownUnits const&) dom/canvas/ImageBitmap.cpp:71:5 #2 0x7fd9a0fd078e in mozilla::dom::CreateImageFromRawData(mozilla::gfx::IntSizeTypedmozilla::gfx::UnknownUnits const&, unsigned int, mozilla::gfx::SurfaceFormat, unsigned char*, unsigned int, mozilla::Maybe<mozilla::gfx::IntRectTypedmozilla::gfx::UnknownUnits > const&, mozilla::ErrorResult&) dom/canvas/ImageBitmap.cpp:132:38 #3 0x7fd9a0fcfa3a in mozilla::dom::ImageBitmap::CreateInternal(nsIGlobalObject*, mozilla::dom::ImageData&, mozilla::Maybe<mozilla::gfx::IntRectTypedmozilla::gfx::UnknownUnits > const&, mozilla::ErrorResult&) dom/canvas/ImageBitmap.cpp:622:12 #4 0x7fd9a0fd3242 in mozilla::dom::ImageBitmap::Create(nsIGlobalObject*, mozilla::dom::HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrCanvasRenderingContext2DOrImageBitmap const&, mozilla::Maybe<mozilla::gfx::IntRectTypedmozilla::gfx::UnknownUnits > const&, mozilla::ErrorResult&) dom/canvas/ImageBitmap.cpp:1069:19 #5 0x7fd99efb7d7b in nsGlobalWindow::CreateImageBitmap(mozilla::dom::HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrCanvasRenderingContext2DOrImageBitmap const&, int, int, int, int, mozilla::ErrorResult&) dom/base/nsGlobalWindow.cpp:14675:10 #6 0x7fd9a062f7ae in mozilla::dom::WindowBinding::createImageBitmap_promiseWrapper(JSContext*, JS::Handle<JSObject*>, nsGlobalWindow*, JSJitMethodCallArgs const&) objdir-ff-asan/dom/bindings/WindowBinding.cpp:11195:57 #7 0x7fd9a061dee0 in mozilla::dom::WindowBinding::genericPromiseReturningMethod(JSContext*, unsigned int, JS::Value*) objdir-ff-asan/dom/bindings/WindowBinding.cpp:13061:13 #8 0x7fd9a60c26b8 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/jscntxtinlines.h:235:15 #9 0x7fd9a61027e0 in Interpret(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:3073:18 #10 0x7fd9a60e5035 in js::RunScript(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:752:12 #11 0x7fd9a60c2dc2 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/vm/Interpreter.cpp:829:15 #12 0x7fd9a605f60b in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandleJS::Value) js/src/vm/Interpreter.cpp:866:10 #13 0x7fd9a6c61f8b in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) js/src/jsapi.cpp:4624:12 #14 0x7fd99fc7e698 in mozilla::dom::AnyCallback::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::MutableHandleJS::Value, mozilla::ErrorResult&) objdir-ff-asan/dom/bindings/PromiseBinding.cpp:78:8 #15 0x7fd9a23fa5a3 in mozilla::dom::WrapperPromiseCallback::Call(JSContext*, JS::HandleJS::Value) objdir-ff-asan/dist/include/mozilla/dom/PromiseBinding.h:134:12 #16 0x7fd9a2401fe9 in mozilla::dom::PromiseCallbackTask::Run() dom/promise/Promise.cpp:98:7 #17 0x7fd9a23e664c in mozilla::dom::Promise::PerformMicroTaskCheckpoint() dom/promise/Promise.cpp:503:19 #18 0x7fd99e1397af in non-virtual thunk to nsXPConnect::AfterProcessNextEvent(nsIThreadInternal*, unsigned int, bool) js/xpconnect/src/nsXPConnect.cpp:1017:5 #19 0x7fd99cd186c3 in nsThread::ProcessNextEvent(bool, bool*) xpcom/threads/nsThread.cpp:885:5 #20 0x7fd99cd8e4ac in NS_ProcessNextEvent(nsIThread*, bool) xpcom/glue/nsThreadUtils.cpp:277:10 #21 0x7fd99d655eae in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ipc/glue/MessagePump.cpp:95:21 #22 0x7fd99d5df8a1 in MessageLoop::Run() ipc/chromium/src/base/message_loop.cc:234:3 #23 0x7fd9a27e4baf in nsBaseAppShell::Run() widget/nsBaseAppShell.cpp:165:3 #24 0x7fd9a4756b33 in XRE_RunAppShell toolkit/xre/nsEmbedFunctions.cpp:785:12 #25 0x7fd99d5df8a1 in MessageLoop::Run() ipc/chromium/src/base/message_loop.cc:234:3 #26 0x7fd9a4756057 in XRE_InitChildProcess toolkit/xre/nsEmbedFunctions.cpp:621:7 #27 0x4dbbf4 in content_process_main(int, char**) ipc/contentproc/plugin-container.cpp:237:19 #28 0x7fd99a0b0ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287 0x61b0000c7480 is located 768 bytes inside of 1424-byte region [0x61b0000c7180,0x61b0000c7710) freed by thread T0 (Web Content) here: #0 0x4b6020 in __interceptor_free asan_rtl #1 0x7fd99e7a808f in mozilla::gfx::DrawTargetCairo::~DrawTargetCairo() gfx/2d/DrawTargetCairo.cpp:597:3 #2 0x7fd99e7a82fd in mozilla::gfx::DrawTargetCairo::~DrawTargetCairo() gfx/2d/DrawTargetCairo.cpp:596:1 #3 0x7fd99ed706ac in mozilla::image::RasterImage::CopyFrame(unsigned int, unsigned int) objdir-ff-asan/dist/include/mozilla/RefPtr.h:142:7 #4 0x7fd99ed70f7b in mozilla::image::RasterImage::GetFrameInternal(unsigned int, unsigned int) image/RasterImage.cpp:736:17 #5 0x7fd99ed70c4d in mozilla::image::RasterImage::GetFrame(unsigned int, unsigned int) image/RasterImage.cpp:697:10 #6 0x7fd9a3125296 in nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent*, unsigned int, mozilla::gfx::DrawTarget*) layout/base/nsLayoutUtils.cpp:6765:29 #7 0x7fd9a3125c8b in nsLayoutUtils::SurfaceFromElement(mozilla::dom::HTMLImageElement*, unsigned int, mozilla::gfx::DrawTarget*) layout/base/nsLayoutUtils.cpp:6805:10 #8 0x7fd9a0fcb942 in mozilla::dom::ImageBitmap::CreateInternal(nsIGlobalObject*, mozilla::dom::HTMLImageElement&, mozilla::Maybe<mozilla::gfx::IntRectTypedmozilla::gfx::UnknownUnits > const&, mozilla::ErrorResult&) dom/canvas/ImageBitmap.cpp:293:5 #9 0x7fd9a0fd2e57 in mozilla::dom::ImageBitmap::Create(nsIGlobalObject*, mozilla::dom::HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrCanvasRenderingContext2DOrImageBitmap const&, mozilla::Maybe<mozilla::gfx::IntRectTypedmozilla::gfx::UnknownUnits > const&, mozilla::ErrorResult&) dom/canvas/ImageBitmap.cpp:1059:19 #10 0x7fd99efb7b48 in nsGlobalWindow::CreateImageBitmap(mozilla::dom::HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrCanvasRenderingContext2DOrImageBitmap const&, mozilla::ErrorResult&) dom/base/nsGlobalWindow.cpp:14667:10 #11 0x7fd9a062fc7f in mozilla::dom::WindowBinding::createImageBitmap_promiseWrapper(JSContext*, JS::Handle<JSObject*>, nsGlobalWindow*, JSJitMethodCallArgs const&) objdir-ff-asan/dom/bindings/WindowBinding.cpp:11142:57 #12 0x7fd9a061dee0 in mozilla::dom::WindowBinding::genericPromiseReturningMethod(JSContext*, unsigned int, JS::Value*) objdir-ff-asan/dom/bindings/WindowBinding.cpp:13061:13 #13 0x7fd9a60c26b8 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/jscntxtinlines.h:235:15 #14 0x7fd9a61027e0 in Interpret(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:3073:18 #15 0x7fd9a60e5035 in js::RunScript(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:752:12 #16 0x7fd9a60c2dc2 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/vm/Interpreter.cpp:829:15 #17 0x7fd9a605f60b in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandleJS::Value) js/src/vm/Interpreter.cpp:866:10 #18 0x7fd9a6c61f8b in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) js/src/jsapi.cpp:4624:12 #19 0x7fd9a0a0575f in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) objdir-ff-asan/dom/bindings/EventHandlerBinding.cpp:259:37 #20 0x7fd9a12a4c0b in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent*) objdir-ff-asan/dist/include/mozilla/dom/EventHandlerBinding.h:351:12 #21 0x7fd9a125dea4 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) dom/events/EventListenerManager.cpp:998:16 #22 0x7fd9a125f6fd in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) dom/events/EventListenerManager.cpp:1147:15 #23 0x7fd9a124cffc in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) dom/events/EventDispatcher.cpp:299:5 #24 0x7fd9a12517cb in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) dom/events/EventDispatcher.cpp:635:9 #25 0x7fd9a122948a in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports, mozilla::WidgetEvent*, nsIDOMEvent*, nsPresContext*, nsEventStatus*) dom/events/EventDispatcher.cpp:702:12 #26 0x7fd99f347711 in nsINode::DispatchEvent(nsIDOMEvent*, bool*) dom/base/nsINode.cpp:1294:5 #27 0x7fd9a120aeba in mozilla::AsyncEventDispatcher::Run() dom/events/AsyncEventDispatcher.cpp:51:3 #28 0x7fd99cd181d6 in nsThread::ProcessNextEvent(bool, bool*) xpcom/threads/nsThread.cpp:867:7 #29 0x7fd99cd8e4ac in NS_ProcessNextEvent(nsIThread*, bool) xpcom/glue/nsThreadUtils.cpp:277:10

previously allocated by thread T0 (Web Content) here: #0 0x4b6338 in __interceptor_malloc asan_rtl #1 0x7fd9a501fbdd in INT__moz_cairo_create gfx/cairo/cairo/src/cairo.c:250:13 #2 0x7fd99e7b8ee9 in mozilla::gfx::DrawTargetCairo::InitAlreadyReferenced(_cairo_surface*, mozilla::gfx::IntSizeTypedmozilla::gfx::UnknownUnits const&, mozilla::gfx::SurfaceFormat*) gfx/2d/DrawTargetCairo.cpp:1578:14 #3 0x7fd99e7ba5a1 in mozilla::gfx::DrawTargetCairo::Init(unsigned char*, mozilla::gfx::IntSizeTypedmozilla::gfx::UnknownUnits const&, int, mozilla::gfx::SurfaceFormat) gfx/2d/DrawTargetCairo.cpp:1671:10 #4 0x7fd99e7e549b in mozilla::gfx::Factory::CreateDrawTargetForData(mozilla::gfx::BackendType, unsigned char*, mozilla::gfx::IntSizeTypedmozilla::gfx::UnknownUnits const&, int, mozilla::gfx::SurfaceFormat) gfx/2d/Factory.cpp:397:11 #5 0x7fd99ed6ff82 in mozilla::image::RasterImage::CopyFrame(unsigned int, unsigned int) image/RasterImage.cpp:657:5 #6 0x7fd99ed70f7b in mozilla::image::RasterImage::GetFrameInternal(unsigned int, unsigned int) image/RasterImage.cpp:736:17 #7 0x7fd99ed70c4d in mozilla::image::RasterImage::GetFrame(unsigned int, unsigned int) image/RasterImage.cpp:697:10 #8 0x7fd9a3125296 in nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent*, unsigned int, mozilla::gfx::DrawTarget*) layout/base/nsLayoutUtils.cpp:6765:29 #9 0x7fd9a3125c8b in nsLayoutUtils::SurfaceFromElement(mozilla::dom::HTMLImageElement*, unsigned int, mozilla::gfx::DrawTarget*) layout/base/nsLayoutUtils.cpp:6805:10 #10 0x7fd9a0fcb942 in mozilla::dom::ImageBitmap::CreateInternal(nsIGlobalObject*, mozilla::dom::HTMLImageElement&, mozilla::Maybe<mozilla::gfx::IntRectTypedmozilla::gfx::UnknownUnits > const&, mozilla::ErrorResult&) dom/canvas/ImageBitmap.cpp:293:5 #11 0x7fd9a0fd2e57 in mozilla::dom::ImageBitmap::Create(nsIGlobalObject*, mozilla::dom::HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrCanvasRenderingContext2DOrImageBitmap const&, mozilla::Maybe<mozilla::gfx::IntRectTypedmozilla::gfx::UnknownUnits > const&, mozilla::ErrorResult&) dom/canvas/ImageBitmap.cpp:1059:19 #12 0x7fd99efb7b48 in nsGlobalWindow::CreateImageBitmap(mozilla::dom::HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrCanvasRenderingContext2DOrImageBitmap const&, mozilla::ErrorResult&) dom/base/nsGlobalWindow.cpp:14667:10 #13 0x7fd9a062fc7f in mozilla::dom::WindowBinding::createImageBitmap_promiseWrapper(JSContext*, JS::Handle<JSObject*>, nsGlobalWindow*, JSJitMethodCallArgs const&) objdir-ff-asan/dom/bindings/WindowBinding.cpp:11142:57 #14 0x7fd9a061dee0 in mozilla::dom::WindowBinding::genericPromiseReturningMethod(JSContext*, unsigned int, JS::Value*) objdir-ff-asan/dom/bindings/WindowBinding.cpp:13061:13 #15 0x7fd9a60c26b8 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/jscntxtinlines.h:235:15 #16 0x7fd9a61027e0 in Interpret(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:3073:18 #17 0x7fd9a60e5035 in js::RunScript(JSContext*, js::RunState&) js/src/vm/Interpreter.cpp:752:12 #18 0x7fd9a60c2dc2 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) js/src/vm/Interpreter.cpp:829:15 #19 0x7fd9a605f60b in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value const*, JS::MutableHandleJS::Value) js/src/vm/Interpreter.cpp:866:10 #20 0x7fd9a6c61f8b in JS::Call(JSContext*, JS::HandleJS::Value, JS::HandleJS::Value, JS::HandleValueArray const&, JS::MutableHandleJS::Value) js/src/jsapi.cpp:4624:12 #21 0x7fd9a0a0575f in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::HandleJS::Value, mozilla::dom::Event&, JS::MutableHandleJS::Value, mozilla::ErrorResult&) objdir-ff-asan/dom/bindings/EventHandlerBinding.cpp:259:37 #22 0x7fd9a12a4c0b in mozilla::JSEventHandler::HandleEvent(nsIDOMEvent*) objdir-ff-asan/dist/include/mozilla/dom/EventHandlerBinding.h:351:12 #23 0x7fd9a125dea4 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) dom/events/EventListenerManager.cpp:998:16 #24 0x7fd9a125f6fd in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) dom/events/EventListenerManager.cpp:1147:15 #25 0x7fd9a124cffc in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArraymozilla::EventTargetChainItem&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) dom/events/EventDispatcher.cpp:299:5 #26 0x7fd9a12517cb in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArraymozilla::dom::EventTarget*) dom/events/EventDispatcher.cpp:635:9 #27 0x7fd9a122948a in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports, mozilla::WidgetEvent*, nsIDOMEvent*, nsPresContext*, nsEventStatus*) dom/events/EventDispatcher.cpp:702:12 #28 0x7fd99f347711 in nsINode::DispatchEvent(nsIDOMEvent*, bool*) dom/base/nsINode.cpp:1294:5 #29 0x7fd9a120aeba in mozilla::AsyncEventDispatcher::Run() dom/events/AsyncEventDispatcher.cpp:51:3

Shadow bytes around the buggy address: 0x0c3680010e40: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010e50: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010e60: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010e70: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010e80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd =>0x0c3680010e90:[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010ea0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010eb0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010ec0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010ed0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c3680010ee0: fd fd fa fa fa fa fa fa fa fa fa fa fa fa fa fa 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 ==29983==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 critical-severity memory corruption bug in Graphics: Canvas2D. Mozilla made it public on 18 August 2015.

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.