Skip to content
Memory corruption Disclosed report CVE-2012-4202

ASAN: Heap-buffer-overflow at image::RasterImage::DrawFrameTo

Atte Kettunen Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 4 months
  • Paid in 14 months
  • Disclosed after 4 months

Created attachment 626785 Repro-gifs and html

This bug seems to be some sort of race condition. The bug is fairly hard to reproduce, but I was able to reproduce it with the files in the attached zip and with the build from http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/[address removed] d/try-linux64-debug/firefox-15.0a1.en-US.linux-x86_64.tar.bz2

ASAN report: ( Using build from http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/[address removed] d/try-linux64-debug/firefox-15.0a1.en-US.linux-x86_64.tar.bz2 )

==31319== ERROR: AddressSanitizer heap-buffer-overflow on address 0x7fd2b6d89e80 at pc 0x7fd305566383 bp 0x7fff393c7c10 sp 0x7fff393c7c08 READ of size 4 at 0x7fd2b6d89e80 thread T0 #0 0x7fd305566383 in mozilla::image::RasterImage::DrawFrameTo(imgFrame*, imgFrame*, nsIntRect&) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:2070 #1 0x7fd30555c2ec in mozilla::image::RasterImage::DoComposite(nsIntRect*, imgFrame*, imgFrame*, int) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:1885 #2 0x7fd30555af67 in mozilla::image::RasterImage::AdvanceFrame(mozilla::TimeStamp, nsIntRect*) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:369 #3 0x7fd30555c96b in mozilla::image::RasterImage::RequestRefresh(mozilla::TimeStamp const&) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:412 #4 0x7fd30575563d in nsRefreshDriver::ImageRequestEnumerator(nsISupportsHashKey*, void*) /builds/slave/try-lnx64-dbg/build/layout/base/nsRefreshDriver.cpp:454 #5 0x7fd3075e906b in PL_DHashTableEnumerate /builds/slave/try-lnx64-dbg/build/obj-firefox/xpcom/build/pldhash.cpp:715 #6 0x7fd30575545a in nsTHashtable<nsISupportsHashKey>::EnumerateEntries(PLDHashOperator ()(nsISupportsHashKey, void*), void*) /builds/slave/try-lnx64-dbg/build/../../dist/include/nsTHashtable.h:237 #7 0x7fd305754dda in nsRefreshDriver::Notify(nsITimer*) /builds/slave/try-lnx64-dbg/build/layout/base/nsRefreshDriver.cpp:410 #8 0x7fd30769fdff in nsTimerImpl::Fire() /builds/slave/try-lnx64-dbg/build/xpcom/threads/nsTimerImpl.cpp:476 #9 0x7fd3076a07fd in nsTimerEvent::Run() /builds/slave/try-lnx64-dbg/build/xpcom/threads/nsTimerImpl.cpp:559 #10 0x7fd30769332d in nsThread::ProcessNextEvent(bool, bool*) /builds/slave/try-lnx64-dbg/build/xpcom/threads/nsThread.cpp:624 #11 0x7fd3075e49e3 in NS_ProcessNextEvent_P(nsIThread*, bool) /builds/slave/try-lnx64-dbg/build/obj-firefox/xpcom/build/nsThreadUtils.cpp:213 #12 0x7fd3073f3cae in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/slave/try-lnx64-dbg/build/ipc/glue/MessagePump.cpp:113 #13 0x7fd307718442 in MessageLoop::RunInternal() /builds/slave/try-lnx64-dbg/build/ipc/chromium/src/base/message_loop.cc:209 #14 0x7fd30771832f in MessageLoop::Run() /builds/slave/try-lnx64-dbg/build/ipc/chromium/src/base/message_loop.cc:176 #15 0x7fd3071b8c52 in nsBaseAppShell::Run() /builds/slave/try-lnx64-dbg/build/widget/xpwidgets/nsBaseAppShell.cpp:165 #16 0x7fd306d77b41 in nsAppStartup::Run() /builds/slave/try-lnx64-dbg/build/toolkit/components/startup/nsAppStartup.cpp:256 #17 0x7fd305187d43 in XREMain::XRE_mainRun() /builds/slave/try-lnx64-dbg/build/toolkit/xre/nsAppRunner.cpp:3765 #18 0x7fd3051890e8 in XREMain::XRE_main(int, char**, nsXREAppData const*) /builds/slave/try-lnx64-dbg/build/toolkit/xre/nsAppRunner.cpp:3842 #19 0x7fd305189b62 in XRE_main /builds/slave/try-lnx64-dbg/build/toolkit/xre/nsAppRunner.cpp:3918 #20 0x4079c2 in do_main(int, char**) /builds/slave/try-lnx64-dbg/build/browser/app/nsBrowserApp.cpp:157 #21 0x4071ba in main /builds/slave/try-lnx64-dbg/build/browser/app/nsBrowserApp.cpp:244 #22 0x7fd30eaf5eff in __libc_start_main /build/buildd/eglibc-2.13/csu/libc-start.c:258 0x7fd2b6d89e80 is located 0 bytes to the right of 513-byte region [0x7fd2b6d89c80,0x7fd2b6d89e81) allocated by thread T0 here: #0 0x4276a2 in malloc ??:0 #1 0x7fd305579808 in imgFrame::Init(int, int, int, int, gfxASurface::gfxImageFormat, unsigned char) /builds/slave/try-lnx64-dbg/build/image/src/imgFrame.cpp:169 #2 0x7fd305561b6e in mozilla::image::RasterImage::InternalAddFrame(unsigned int, int, int, int, int, gfxASurface::gfxImageFormat, unsigned char, unsigned char**, unsigned int*, unsigned int**, unsigned int*) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:1044 #3 0x7fd3055623be in mozilla::image::RasterImage::EnsureFrame(unsigned int, int, int, int, int, gfxASurface::gfxImageFormat, unsigned char, unsigned char**, unsigned int*, unsigned int**, unsigned int*) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:1145 #4 0x7fd3055b4e96 in mozilla::image::nsGIFDecoder2::BeginImageFrame(unsigned short) /builds/slave/try-lnx64-dbg/build/image/decoders/nsGIFDecoder2.cpp:185 #5 0x7fd3055b8ecd in mozilla::image::nsGIFDecoder2::WriteInternal(char const*, unsigned int) /builds/slave/try-lnx64-dbg/build/image/decoders/nsGIFDecoder2.cpp:922 #6 0x7fd305563fde in mozilla::image::RasterImage::WriteToDecoder(char const*, unsigned int) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:2378 #7 0x7fd305568374 in mozilla::image::RasterImage::DecodeSomeData(unsigned int) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:2731 #8 0x7fd305569105 in mozilla::image::RasterImage::DecodeWorker::DecodeSomeOfImage(mozilla::image::RasterImage*, mozilla::image::RasterImage::DecodeWorker::DecodeType) /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:3028 #9 0x7fd305568a7d in mozilla::image::RasterImage::DecodeWorker::Run() /builds/slave/try-lnx64-dbg/build/image/src/RasterImage.cpp:2957 #10 0x7fd30769332d in nsThread::ProcessNextEvent(bool, bool*) /builds/slave/try-lnx64-dbg/build/xpcom/threads/nsThread.cpp:624 #11 0x7fd3075e49e3 in NS_ProcessNextEvent_P(nsIThread*, bool) /builds/slave/try-lnx64-dbg/build/obj-firefox/xpcom/build/nsThreadUtils.cpp:213 #12 0x7fd3073f3cc9 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/slave/try-lnx64-dbg/build/ipc/glue/MessagePump.cpp:82 #13 0x7fd307718442 in MessageLoop::RunInternal() /builds/slave/try-lnx64-dbg/build/ipc/chromium/src/base/message_loop.cc:209 #14 0x7fd30771832f in MessageLoop::Run() /builds/slave/try-lnx64-dbg/build/ipc/chromium/src/base/message_loop.cc:176 #15 0x7fd3071b8c52 in nsBaseAppShell::Run() /builds/slave/try-lnx64-dbg/build/widget/xpwidgets/nsBaseAppShell.cpp:165 #16 0x7fd306d77b41 in nsAppStartup::Run() /builds/slave/try-lnx64-dbg/build/toolkit/components/startup/nsAppStartup.cpp:256 #17 0x7fd305187d43 in XREMain::XRE_mainRun() /builds/slave/try-lnx64-dbg/build/toolkit/xre/nsAppRunner.cpp:3765 #18 0x7fd3051890e8 in XREMain::XRE_main(int, char**, nsXREAppData const*) /builds/slave/try-lnx64-dbg/build/toolkit/xre/nsAppRunner.cpp:3842 #19 0x7fd305189b62 in XRE_main /builds/slave/try-lnx64-dbg/build/toolkit/xre/nsAppRunner.cpp:3918 #20 0x4079c2 in do_main(int, char**) /builds/slave/try-lnx64-dbg/build/browser/app/nsBrowserApp.cpp:157 #21 0x4071ba in main /builds/slave/try-lnx64-dbg/build/browser/app/nsBrowserApp.cpp:244 ==31319== ABORTING Stats: 1296M malloced (1238M for red zones) by 2598427 calls Stats: 340M realloced by 249611 calls Stats: 1243M freed by 2350356 calls Stats: 1114M really freed by 2040296 calls Stats: 812M (208022 full pages) mmaped in 203 calls mmaps by size class: 8:442341; 9:90101; 10:28665; 11:16376; 12:5120; 13:5120; 14:2048; 15:1024; 16:1088; 17:160; 18:208; 19:72; 20:140; 21:78; 22:1; mallocs by size class: 8:1938088; 9:399426; 10:123808; 11:66502; 12:21500; 13:26796; 14:10485; 15:6225; 16:4102; 17:434; 18:590; 19:92; 20:300; 21:78; 22:1; frees by size class: 8:1733745; 9:371387; 10:116404; 11:61308; 12:20229; 13:25807; 14:9918; 15:6176; 16:3939; 17:423; 18:552; 19:91; 20:299; 21:77; 22:1; rfrees by size class: 8:1508469; 9:319321; 10:101173; 11:53186; 12:17227; 13:22292; 14:8562; 15:5231; 16:3485; 17:382; 18:522; 19:89; 20:279; 21:77; 22:1; Stats: malloc large: 1495 small slow: 14726 Shadow byte and word: 0x1ffa56db13d0: 1 0x1ffa56db13d0: 01 fb fb fb fb fb fb fb More shadow bytes: 0x1ffa56db13b0: 00 00 00 00 00 00 00 00 0x1ffa56db13b8: 00 00 00 00 00 00 00 00 0x1ffa56db13c0: 00 00 00 00 00 00 00 00 0x1ffa56db13c8: 00 00 00 00 00 00 00 00 =>0x1ffa56db13d0: 01 fb fb fb fb fb fb fb 0x1ffa56db13d8: fb fb fb fb fb fb fb fb 0x1ffa56db13e0: fa fa fa fa fa fa fa fa 0x1ffa56db13e8: fa fa fa fa fa fa fa fa 0x1ffa56db13f0: fa fa fa fa fa fa fa fa

The original report as published on Mozilla's Bugzilla, by Atte Kettunen. 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: ImageLib. Mozilla made it public on 22 September 2012 as CVE-2012-4202.

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 Atte Kettunen

View all

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