{"id":640,"date":"2016-10-07T11:12:58","date_gmt":"2016-10-07T09:12:58","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=640"},"modified":"2016-10-16T11:40:35","modified_gmt":"2016-10-16T09:40:35","slug":"imagemagick-heap-based-buffer-overflow-in-ispixelmonochrome-pixel-accessor-h","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2016\/10\/07\/imagemagick-heap-based-buffer-overflow-in-ispixelmonochrome-pixel-accessor-h\/","title":{"rendered":"imagemagick: heap-based buffer overflow in IsPixelMonochrome (pixel-accessor.h)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"http:\/\/www.imagemagick.org\/script\/index.php\">imagemagick<\/a> is a software suite to create, edit, compose, or convert bitmap images.<\/p>\n<p>A fuzzing with the upstream <a href=\"http:\/\/www.imagemagick.org\/script\/security-policy.php\">security policy<\/a> enabled revealed a buffer overflow read.<\/p>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># identify $FILE\r\n==13198==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61400000fbc0 at pc 0x7f7a28f71a91 bp 0x7fff6820aaa0 sp 0x7fff6820aa98                                                                                                                                      \r\nREAD of size 10 at 0x61400000fbc0 thread T0                                                                                                                                                                                                                                    \r\n    #0 0x7f7a28f71a90 in IsPixelMonochrome \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/.\/MagickCore\/pixel-accessor.h:557:24                                                                                                                            \r\n    #1 0x7f7a28f71a90 in IdentifyImageMonochrome \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/attribute.c:758                                                                                                                                \r\n    #2 0x7f7a28f71dc6 in IdentifyImageType \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/attribute.c:819:7                                                                                                                                    \r\n    #3 0x7f7a293216ce in IdentifyImage \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/identify.c:524:8                                                                                                                                         \r\n    #4 0x7f7a28924f86 in IdentifyImageCommand \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickWand\/identify.c:336:22                                                                                                                                 \r\n    #5 0x7f7a289ba26a in MagickCommandGenesis \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickWand\/mogrify.c:183:14                                                                                                                                  \r\n    #6 0x4f1fb5 in MagickMain \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/utilities\/magick.c:145:10                                                                                                                                                    \r\n    #7 0x4f1fb5 in main \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/utilities\/magick.c:176                                                                                                                                                             \r\n    #8 0x7f7a2785e61f in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.22-r4\/work\/glibc-2.22\/csu\/libc-start.c:289                                                                                                                                                        \r\n    #9 0x419138 in _init (\/usr\/bin\/magick+0x419138)                                                                                                                                                                                                                            \r\n\r\n0x61400000fbc0 is located 0 bytes to the right of 384-byte region [0x61400000fa40,0x61400000fbc0)                                                                                                                                                                              \r\nallocated by thread T0 here:                                                                                                                                                                                                                                                   \r\n    #0 0x4c1105 in __interceptor_posix_memalign \/var\/tmp\/portage\/sys-devel\/llvm-3.8.1-r2\/work\/llvm-3.8.1.src\/projects\/compiler-rt\/lib\/asan\/asan_malloc_linux.cc:124                                                                                                            \r\n    #1 0x7f7a293cac65 in AcquireAlignedMemory \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/memory.c:258:7\r\n    #2 0x7f7a28fb8e9d in AcquireCacheNexusPixels \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/cache.c:4634:33\r\n    #3 0x7f7a28fb8e9d in SetPixelCacheNexusPixels \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/cache.c:4746\r\n    #4 0x7f7a28fa9f9e in GetVirtualPixelsFromNexus \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/cache.c:2629:10\r\n    #5 0x7f7a28fd2a5e in GetCacheViewVirtualPixels \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/cache-view.c:664:10\r\n    #6 0x7f7a28f70e46 in IdentifyImageMonochrome \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/attribute.c:753:7\r\n    #7 0x7f7a28f71dc6 in IdentifyImageType \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/attribute.c:819:7\r\n    #8 0x7f7a293216ce in IdentifyImage \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickCore\/identify.c:524:8\r\n    #9 0x7f7a28924f86 in IdentifyImageCommand \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickWand\/identify.c:336:22\r\n    #10 0x7f7a289ba26a in MagickCommandGenesis \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/MagickWand\/mogrify.c:183:14\r\n    #11 0x4f1fb5 in MagickMain \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/utilities\/magick.c:145:10\r\n    #12 0x4f1fb5 in main \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/utilities\/magick.c:176\r\n    #13 0x7f7a2785e61f in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.22-r4\/work\/glibc-2.22\/csu\/libc-start.c:289\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/tmp\/portage\/media-gfx\/imagemagick-7.0.3.0\/work\/ImageMagick-7.0.3-0\/.\/MagickCore\/pixel-accessor.h:557:24 in IsPixelMonochrome\r\nShadow bytes around the buggy address:\r\n  0x0c287fff9f20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c287fff9f30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c287fff9f40: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00\r\n  0x0c287fff9f50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c287fff9f60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n=&gt;0x0c287fff9f70: 00 00 00 00 00 00 00 00[fa]fa fa fa fa fa fa fa\r\n  0x0c287fff9f80: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd\r\n  0x0c287fff9f90: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd\r\n  0x0c287fff9fa0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd\r\n  0x0c287fff9fb0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa\r\n  0x0c287fff9fc0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00\r\nShadow byte legend (one shadow byte represents 8 application bytes):\r\n  Addressable:           00\r\n  Partially addressable: 01 02 03 04 05 06 07 \r\n  Heap left redzone:       fa\r\n  Heap right redzone:      fb\r\n  Freed heap region:       fd\r\n  Stack left redzone:      f1\r\n  Stack mid redzone:       f2\r\n  Stack right redzone:     f3\r\n  Stack partial redzone:   f4\r\n  Stack after return:      f5\r\n  Stack use after scope:   f8\r\n  Global redzone:          f9\r\n  Global init order:       f6\r\n  Poisoned by user:        f7\r\n  Container overflow:      fc\r\n  Array cookie:            ac\r\n  Intra object redzone:    bb\r\n  ASan internal:           fe\r\n  Left alloca redzone:     ca\r\n  Right alloca redzone:    cb\r\n==13198==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\nTested on 7.0.3.0 but 7.0.3.1\/7.0.3.2 did not include any fix<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo of Gentoo.<\/p>\n<p><strong>CVE:<\/strong><br \/>\nCVE-2016-8678<\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2016-09-14: bug discovered<br \/>\n2016-09-14: bug reported to upstream<br \/>\n2016-10-07: blog post about the issue<br \/>\n2016-10-16: CVE Assigned<\/p>\n<p><strong>Note:<\/strong><br \/>\nThis bug was found with <a href=\"http:\/\/lcamtuf.coredump.cx\/afl\">American Fuzzy Lop<\/a>.<\/p>\n<p><strong>Permalink:<\/strong><\/p>\n<blockquote data-secret=\"6KsqUHcqEz\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2016\/10\/07\/imagemagick-heap-based-buffer-overflow-in-ispixelmonochrome-pixel-accessor-h\/\">imagemagick: heap-based buffer overflow in IsPixelMonochrome (pixel-accessor.h)<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/blogs.gentoo.org\/ago\/2016\/10\/07\/imagemagick-heap-based-buffer-overflow-in-ispixelmonochrome-pixel-accessor-h\/embed\/#?secret=6KsqUHcqEz\" data-secret=\"6KsqUHcqEz\" width=\"600\" height=\"338\" title=\"&#8220;imagemagick: heap-based buffer overflow in IsPixelMonochrome (pixel-accessor.h)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: imagemagick is a software suite to create, edit, compose, or convert bitmap images. A fuzzing with the upstream security policy enabled revealed a buffer overflow read. The complete ASan output: # identify $FILE ==13198==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61400000fbc0 &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2016\/10\/07\/imagemagick-heap-based-buffer-overflow-in-ispixelmonochrome-pixel-accessor-h\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":140,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[12,10],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2EaBc-ak","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/640"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/users\/140"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/comments?post=640"}],"version-history":[{"count":6,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/640\/revisions"}],"predecessor-version":[{"id":719,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/640\/revisions\/719"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}