{"id":1827,"date":"2017-05-24T15:24:03","date_gmt":"2017-05-24T13:24:03","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1827"},"modified":"2017-06-07T14:40:07","modified_gmt":"2017-06-07T12:40:07","slug":"ytnef-heap-based-buffer-overflow-in-swapdword-ytnef-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/05\/24\/ytnef-heap-based-buffer-overflow-in-swapdword-ytnef-c\/","title":{"rendered":"ytnef: heap-based buffer overflow in SwapDWord (ytnef.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/github.com\/Yeraze\/ytnef\">ytnef<\/a> is Yeraze&#8217;s TNEF Stream Reader &#8211; for winmail.dat files.<\/p>\n<p>The complete ASan output of the issue:<\/p>\n<pre><font size=\"2\"># ytnefprint $FILE\r\n==12532==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000014 at pc 0x7f8e3c35544e bp 0x7ffeb883d890 sp 0x7ffeb883d888                                                                         \r\nREAD of size 1 at 0x602000000014 thread T0                                                                                                                                                                        \r\n    #0 0x7f8e3c35544d in SwapDWord \/tmp\/ytnef-1.9.2\/lib\/ytnef.c:180:28                                                                                                                                            \r\n    #1 0x7f8e3c35544d in TNEFFillMapi \/tmp\/ytnef-1.9.2\/lib\/ytnef.c:430                                                                                                                                            \r\n    #2 0x7f8e3c360b47 in TNEFParse \/tmp\/ytnef-1.9.2\/lib\/ytnef.c:1184:15                                                                                                                                           \r\n    #3 0x7f8e3c35f9d3 in TNEFParseFile \/tmp\/ytnef-1.9.2\/lib\/ytnef.c:1042:10                                                                                                                                       \r\n    #4 0x508814 in main \/tmp\/ytnef-1.9.2\/ytnefprint\/main.c:80:9                                                                                                                                                   \r\n    #5 0x7f8e3b47578f in __libc_start_main \/tmp\/portage\/sys-libs\/glibc-2.23-r3\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289                                                                                        \r\n    #6 0x419c38 in _start (\/usr\/bin\/ytnefprint+0x419c38)                                                                                                                                                          \r\n                                                                                                                                                                                                                  \r\n0x602000000014 is located 0 bytes to the right of 4-byte region [0x602000000010,0x602000000014)                                                                                                                   \r\nallocated by thread T0 here:                                                                                                                                                                                      \r\n    #0 0x4cf7e0 in calloc \/tmp\/portage\/sys-libs\/compiler-rt-sanitizers-4.0.0\/work\/compiler-rt-4.0.0.src\/lib\/asan\/asan_malloc_linux.cc:74                                                                          \r\n    #1 0x7f8e3c36072a in TNEFParse \/tmp\/ytnef-1.9.2\/lib\/ytnef.c:1154:12                                                                                                                                           \r\n    #2 0x7f8e3c35f9d3 in TNEFParseFile \/tmp\/ytnef-1.9.2\/lib\/ytnef.c:1042:10                                                                                                                                       \r\n    #3 0x508814 in main \/tmp\/ytnef-1.9.2\/ytnefprint\/main.c:80:9                                                                                                                                                   \r\n    #4 0x7f8e3b47578f 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\/ytnef-1.9.2\/lib\/ytnef.c:180:28 in SwapDWord                                                                                                                  \r\nShadow bytes around the buggy address:                                                                                                                                                                            \r\n  0x0c047fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                                                                                                 \r\n  0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                                                                                                 \r\n  0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                                                                                                 \r\n  0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                                                                                                 \r\n  0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00                                                                                                                                                 \r\n=&gt;0x0c047fff8000: fa fa[04]fa fa fa fa fa fa fa fa fa fa fa fa fa                                                                                                                                                 \r\n  0x0c047fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa                                                                                                                                                 \r\n  0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa                                                                                                                                                 \r\n  0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa                                                                                                                                                 \r\n  0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa                                                                                                                                                 \r\n  0x0c047fff8050: 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==12532==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n1.9.2<\/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-2017-9472<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00245-ytnef-heapoverflow-SwapDWord\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00245-ytnef-heapoverflow-SwapDWord<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-03-27: bug discovered and reported to upstream<br \/>\n2017-05-24: blog post about the issue<br \/>\n2017-06-07: 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=\"oav7qemccM\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/05\/24\/ytnef-heap-based-buffer-overflow-in-swapdword-ytnef-c\/\">ytnef: heap-based buffer overflow in SwapDWord (ytnef.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\/05\/24\/ytnef-heap-based-buffer-overflow-in-swapdword-ytnef-c\/embed\/#?secret=oav7qemccM\" data-secret=\"oav7qemccM\" width=\"600\" height=\"338\" title=\"&#8220;ytnef: heap-based buffer overflow in SwapDWord (ytnef.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: ytnef is Yeraze&#8217;s TNEF Stream Reader &#8211; for winmail.dat files. The complete ASan output of the issue: # ytnefprint $FILE ==12532==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000014 at pc 0x7f8e3c35544e bp 0x7ffeb883d890 sp 0x7ffeb883d888 READ of size 1 at 0x602000000014 &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/05\/24\/ytnef-heap-based-buffer-overflow-in-swapdword-ytnef-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-tt","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1827"}],"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=1827"}],"version-history":[{"count":4,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1827\/revisions"}],"predecessor-version":[{"id":1870,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1827\/revisions\/1870"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}