{"id":1667,"date":"2017-04-27T21:42:16","date_gmt":"2017-04-27T19:42:16","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1667"},"modified":"2017-04-30T11:08:33","modified_gmt":"2017-04-30T09:08:33","slug":"imageworsener-heap-based-buffer-overflow-in-iw_process_cols_to_intermediate-imagew-main-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/04\/27\/imageworsener-heap-based-buffer-overflow-in-iw_process_cols_to_intermediate-imagew-main-c\/","title":{"rendered":"imageworsener: heap-based buffer overflow in iw_process_cols_to_intermediate (imagew-main.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/github.com\/jsummers\/imageworsener\">imageworsener<\/a> is a utility for image scaling and processing.<\/p>\n<p>The complete ASan output of the issue:<\/p>\n<pre><font size=\"2\"># imagew $FILE \/tmp\/out -outfmt bmp\r\n==20314==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7fe233b99af8 at pc 0x7fea7f55da64 bp 0x7ffdb4737840 sp 0x7ffdb4737838                                                                         \r\nWRITE of size 4 at 0x7fe233b99af8 thread T0                                                                                                                                                                       \r\n    #0 0x7fea7f55da63 in iw_process_cols_to_intermediate \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-main.c:903:75                                                             \r\n    #1 0x7fea7f55da63 in iw_process_one_channel \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-main.c:1144                                                                        \r\n    #2 0x7fea7f54ca71 in iw_process_internal \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-main.c:1405:7                                                                         \r\n    #3 0x7fea7f520095 in iw_process_image \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-main.c:2248:8                                                                            \r\n    #4 0x528de1 in iwcmd_run \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-cmd.c:1400:6                                                                                          \r\n    #5 0x515326 in iwcmd_main \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-cmd.c:3018:7                                                                                         \r\n    #6 0x515326 in main \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-cmd.c:3067                                                                                                 \r\n    #7 0x7fea7e5e878f in __libc_start_main \/tmp\/portage\/sys-libs\/glibc-2.23-r3\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289                                                                                        \r\n    #8 0x41b028 in _init (\/usr\/bin\/imagew+0x41b028)                                                                                                                                                               \r\n                                                                                                                                                                                                                  \r\n0x7fe233b99af8 is located 4 bytes to the right of 8003134196-byte region [0x7fe056b37800,0x7fe233b99af4)                                                                                                          \r\nallocated by thread T0 here:                                                                                                                                                                                      \r\n    #0 0x4da6f8 in malloc \/tmp\/portage\/sys-libs\/compiler-rt-sanitizers-4.0.0\/work\/compiler-rt-4.0.0.src\/lib\/asan\/asan_malloc_linux.cc:66                                                                          \r\n    #1 0x551fc0 in my_mallocfn \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-cmd.c:794:9                                                                                         \r\n    #2 0x7fea7f6a39ae in iw_malloc_ex \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-util.c:48:8                                                                                  \r\n    #3 0x7fea7f6a3dec in iw_malloc_large \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-util.c:77:9                                                                               \r\n    #4 0x7fea7f54c5a0 in iw_process_internal \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-main.c:1396:44                                                                        \r\n    #5 0x7fea7f520095 in iw_process_image \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-main.c:2248:8                                                                            \r\n    #6 0x528de1 in iwcmd_run \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-cmd.c:1400:6                                                                                          \r\n    #7 0x515326 in iwcmd_main \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-cmd.c:3018:7                                                                                         \r\n    #8 0x515326 in main \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-cmd.c:3067                                                                                                 \r\n    #9 0x7fea7e5e878f in __libc_start_main \/tmp\/portage\/sys-libs\/glibc-2.23-r3\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/tmp\/portage\/media-gfx\/imageworsener-1.3.0\/work\/imageworsener-1.3.0\/src\/imagew-main.c:903:75 in iw_process_cols_to_intermediate\r\nShadow bytes around the buggy address:\r\n  0x0ffcc676b300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0ffcc676b310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0ffcc676b320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0ffcc676b330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0ffcc676b340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n=&gt;0x0ffcc676b350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04[fa]\r\n  0x0ffcc676b360: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0ffcc676b370: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0ffcc676b380: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0ffcc676b390: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0ffcc676b3a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\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  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 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==20314==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n1.3.0<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\n1.3.1<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/jsummers\/imageworsener\/commit\/86564051db45b466e5f667111ce00b5eeedc8fb6\">https:\/\/github.com\/jsummers\/imageworsener\/commit\/86564051db45b466e5f667111ce00b5eeedc8fb6<\/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-2017-8325<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00269-imageworsener-heapoverflow-iw_process_cols_to_intermediate\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00269-imageworsener-heapoverflow-iw_process_cols_to_intermediate<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-04-12: bug discovered and reported to upstream<br \/>\n2017-04-12: upstream released a patch<br \/>\n2017-04-27: blog post about the issue<br \/>\n2017-04-29: 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=\"SkJwmnUrY6\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/04\/27\/imageworsener-heap-based-buffer-overflow-in-iw_process_cols_to_intermediate-imagew-main-c\/\">imageworsener: heap-based buffer overflow in iw_process_cols_to_intermediate (imagew-main.c)<\/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\/2017\/04\/27\/imageworsener-heap-based-buffer-overflow-in-iw_process_cols_to_intermediate-imagew-main-c\/embed\/#?secret=SkJwmnUrY6\" data-secret=\"SkJwmnUrY6\" width=\"600\" height=\"338\" title=\"&#8220;imageworsener: heap-based buffer overflow in iw_process_cols_to_intermediate (imagew-main.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: imageworsener is a utility for image scaling and processing. The complete ASan output of the issue: # imagew $FILE \/tmp\/out -outfmt bmp ==20314==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7fe233b99af8 at pc 0x7fea7f55da64 bp 0x7ffdb4737840 sp 0x7ffdb4737838 WRITE of size 4 &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/04\/27\/imageworsener-heap-based-buffer-overflow-in-iw_process_cols_to_intermediate-imagew-main-c\/\">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-qT","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1667"}],"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=1667"}],"version-history":[{"count":4,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1667\/revisions"}],"predecessor-version":[{"id":1713,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1667\/revisions\/1713"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}