{"id":1360,"date":"2017-02-20T16:25:39","date_gmt":"2017-02-20T14:25:39","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1360"},"modified":"2017-03-13T11:07:22","modified_gmt":"2017-03-13T09:07:22","slug":"audiofile-global-buffer-overflow-in-decodesample-ima-cpp","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/02\/20\/audiofile-global-buffer-overflow-in-decodesample-ima-cpp\/","title":{"rendered":"audiofile: global buffer overflow in decodeSample (IMA.cpp)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"http:\/\/www.68k.org\/~michael\/audiofile\/\">audiofile<\/a> is a C-based library for reading and writing audio files in many common formats.<\/p>\n<p>A fuzz on it discovered a global overflow.<\/p>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># sfconvert @@ out.mp3 format aiff                                                                                                                                                                                                                                               \r\n==1779==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f0add7e6a7a at pc 0x7f0add77c221 bp 0x7ffe13caabf0 sp 0x7ffe13caabe8\r\nREAD of size 2 at 0x7f0add7e6a7a thread T0\r\n    #0 0x7f0add77c220 in decodeSample(adpcmState&amp;, unsigned char) \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/modules\/IMA.cpp:144:13\r\n    #1 0x7f0add77c220 in IMA::decodeBlockWAVE(unsigned char const*, short*) \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/modules\/IMA.cpp:186\r\n    #2 0x7f0add77b671 in IMA::decodeBlock(unsigned char const*, short*) \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/modules\/IMA.cpp:110:10\r\n    #3 0x7f0add777ac9 in BlockCodec::runPull() \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/modules\/BlockCodec.cpp:55:3\r\n    #4 0x7f0add7b0c20 in RebufferModule::runPull() \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/modules\/RebufferModule.cpp:122:3\r\n    #5 0x7f0add76105a in afReadFrames \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/data.cpp:222:14\r\n    #6 0x50bbeb in copyaudiodata \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/sfcommands\/sfconvert.c:340:29\r\n    #7 0x50b050 in main \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/sfcommands\/sfconvert.c:248:17\r\n    #8 0x7f0adc83678f in __libc_start_main \/tmp\/portage\/sys-libs\/glibc-2.23-r3\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289\r\n    #9 0x419f48 in _init (\/usr\/bin\/sfconvert+0x419f48)\r\n\r\n0x7f0add7e6a7a is located 6 bytes to the left of global variable 'indexTable' defined in '\/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/modules\/IMA.cpp:116:21' (0x7f0add7e6a80) of size 16\r\n0x7f0add7e6a7a is located 40 bytes to the right of global variable 'stepTable' defined in '\/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/modules\/IMA.cpp:122:22' (0x7f0add7e69a0) of size 178\r\nSUMMARY: AddressSanitizer: global-buffer-overflow \/tmp\/portage\/media-libs\/audiofile-0.3.6-r1\/work\/audiofile-0.3.6\/libaudiofile\/modules\/IMA.cpp:144:13 in decodeSample(adpcmState&amp;, unsigned char)\r\nShadow bytes around the buggy address:\r\n  0x0fe1dbaf4cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0fe1dbaf4d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 07 f9 f9\r\n  0x0fe1dbaf4d10: f9 f9 f9 f9 00 00 00 00 00 00 00 04 f9 f9 f9 f9\r\n  0x0fe1dbaf4d20: 00 00 00 00 00 00 01 f9 f9 f9 f9 f9 00 00 01 f9\r\n  0x0fe1dbaf4d30: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00\r\n=&gt;0x0fe1dbaf4d40: 00 00 00 00 00 00 00 00 00 00 02 f9 f9 f9 f9[f9]\r\n  0x0fe1dbaf4d50: 00 00 f9 f9 f9 f9 f9 f9 00 00 03 f9 f9 f9 f9 f9\r\n  0x0fe1dbaf4d60: 00 00 05 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00\r\n  0x0fe1dbaf4d70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0fe1dbaf4d80: 00 00 00 00 01 f9 f9 f9 f9 f9 f9 f9 00 00 00 00\r\n  0x0fe1dbaf4d90: 00 00 00 00 00 00 00 00 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==1779==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n0.3.6<\/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-6829<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00183-audiofile-globaloverflow-decodeSample\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00183-audiofile-globaloverflow-decodeSample<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-02-20: bug discovered and reported to upstream<br \/>\n2017-02-20: blog post about the issue<br \/>\n2017-03-12: 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=\"xuvEr1IZ4y\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/02\/20\/audiofile-global-buffer-overflow-in-decodesample-ima-cpp\/\">audiofile: global buffer overflow in decodeSample (IMA.cpp)<\/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\/02\/20\/audiofile-global-buffer-overflow-in-decodesample-ima-cpp\/embed\/#?secret=xuvEr1IZ4y\" data-secret=\"xuvEr1IZ4y\" width=\"600\" height=\"338\" title=\"&#8220;audiofile: global buffer overflow in decodeSample (IMA.cpp)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: audiofile is a C-based library for reading and writing audio files in many common formats. A fuzz on it discovered a global overflow. The complete ASan output: # sfconvert @@ out.mp3 format aiff ==1779==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f0add7e6a7a &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/02\/20\/audiofile-global-buffer-overflow-in-decodesample-ima-cpp\/\">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-lW","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1360"}],"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=1360"}],"version-history":[{"count":5,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1360\/revisions"}],"predecessor-version":[{"id":1432,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1360\/revisions\/1432"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}