{"id":1679,"date":"2017-04-29T15:25:09","date_gmt":"2017-04-29T13:25:09","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1679"},"modified":"2017-05-01T13:20:20","modified_gmt":"2017-05-01T11:20:20","slug":"libsndfile-global-buffer-overflow-in-flac_buffer_copy-flac-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/04\/29\/libsndfile-global-buffer-overflow-in-flac_buffer_copy-flac-c\/","title":{"rendered":"libsndfile: global buffer overflow in flac_buffer_copy (flac.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"http:\/\/www.mega-nerd.com\/libsndfile\">libsndfile<\/a> is a C library for reading and writing files containing sampled sound.<\/p>\n<p>The complete ASan output of the issue:<\/p>\n<pre><font size=\"2\"># sndfile-convert $FILE out.wav\r\n==24715==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000013cc140 at pc 0x7f4f387e75ee bp 0x7ffe9d102370 sp 0x7ffe9d102368\r\nWRITE of size 4 at 0x0000013cc140 thread T0\r\n    #0 0x7f4f387e75ed in flac_buffer_copy \/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/src\/flac.c:267:27\r\n    #1 0x7f4f387db2fa in sf_flac_write_callback \/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/src\/flac.c:390:2\r\n    #2 0x7f4f3748f6ad in write_audio_frame_to_client_ \/tmp\/portage\/media-libs\/flac-1.3.2-r1\/work\/flac-1.3.2\/src\/libFLAC\/stream_decoder.c:2981\r\n    #3 0x7f4f3748f6ad in read_frame_ \/tmp\/portage\/media-libs\/flac-1.3.2-r1\/work\/flac-1.3.2\/src\/libFLAC\/stream_decoder.c:2152\r\n    #4 0x7f4f37491aef in FLAC__stream_decoder_process_single \/tmp\/portage\/media-libs\/flac-1.3.2-r1\/work\/flac-1.3.2\/src\/libFLAC\/stream_decoder.c:1027\r\n    #5 0x7f4f387e7fbb in flac_read_loop \/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/src\/flac.c:932:8\r\n    #6 0x7f4f387d31fb in flac_read_flac2i \/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/src\/flac.c:979:13\r\n    #7 0x7f4f3872b3a2 in sf_readf_int \/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/src\/sndfile.c:1835:10\r\n    #8 0x514b5d in sfe_copy_data_int \/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/programs\/common.c:87:16\r\n    #9 0x5138d1 in main \/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/programs\/sndfile-convert.c:340:3\r\n    #10 0x7f4f376c678f in __libc_start_main \/tmp\/portage\/sys-libs\/glibc-2.23-r3\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289\r\n    #11 0x419e18 in _init (\/usr\/bin\/sndfile-convert+0x419e18)\r\n\r\n0x0000013cc140 is located 0 bytes to the right of global variable 'data' defined in '\/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/programs\/common.c:80:14' (0x13c8140) of size 16384\r\nSUMMARY: AddressSanitizer: global-buffer-overflow \/tmp\/portage\/media-libs\/libsndfile-1.0.28\/work\/libsndfile-1.0.28\/src\/flac.c:267:27 in flac_buffer_copy\r\nShadow bytes around the buggy address:\r\n  0x0000802717d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0000802717e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0000802717f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x000080271800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x000080271810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n=&gt;0x000080271820: 00 00 00 00 00 00 00 00[f9]f9 f9 f9 f9 f9 f9 f9\r\n  0x000080271830: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x000080271840: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x000080271850: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x000080271860: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x000080271870: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\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==24715==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n1.0.28<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/erikd\/libsndfile\/commit\/fd0484aba8e51d16af1e3a880f9b8b857b385eb3\">https:\/\/github.com\/erikd\/libsndfile\/commit\/fd0484aba8e51d16af1e3a880f9b8b857b385eb3<\/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-8361<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00265-libsndfile-globaloverflow-flac_buffer_copy\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00265-libsndfile-globaloverflow-flac_buffer_copy<\/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-29: blog post about the issue<br \/>\n2017-04-30: 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=\"DoNViyMjRQ\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/04\/29\/libsndfile-global-buffer-overflow-in-flac_buffer_copy-flac-c\/\">libsndfile: global buffer overflow in flac_buffer_copy (flac.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\/29\/libsndfile-global-buffer-overflow-in-flac_buffer_copy-flac-c\/embed\/#?secret=DoNViyMjRQ\" data-secret=\"DoNViyMjRQ\" width=\"600\" height=\"338\" title=\"&#8220;libsndfile: global buffer overflow in flac_buffer_copy (flac.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: libsndfile is a C library for reading and writing files containing sampled sound. The complete ASan output of the issue: # sndfile-convert $FILE out.wav ==24715==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000013cc140 at pc 0x7f4f387e75ee bp 0x7ffe9d102370 sp 0x7ffe9d102368 WRITE of &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/04\/29\/libsndfile-global-buffer-overflow-in-flac_buffer_copy-flac-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-r5","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1679"}],"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=1679"}],"version-history":[{"count":2,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1679\/revisions"}],"predecessor-version":[{"id":1730,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1679\/revisions\/1730"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}