{"id":2322,"date":"2017-10-03T16:24:05","date_gmt":"2017-10-03T14:24:05","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=2322"},"modified":"2017-10-04T12:58:07","modified_gmt":"2017-10-04T10:58:07","slug":"binutils-heap-based-buffer-overflow-in-bfd_getl32-opncls-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/10\/03\/binutils-heap-based-buffer-overflow-in-bfd_getl32-opncls-c\/","title":{"rendered":"binutils: heap-based buffer overflow in bfd_get_debug_link_info_1 (opncls.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/sourceware.org\/binutils\/\">binutils<\/a> is a set of tools necessary to build programs.<\/p>\n<p>The complete ASan output of the issue:<\/p>\n<pre><font size=\"2\"># nm -A -a -l -S -s --special-syms --synthetic --with-symbol-versions -D $FILE\r\n==11994==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000029e at pc 0x7f800af7095d bp 0x7ffeab0e5c90 sp 0x7ffeab0e5c88            \r\nREAD of size 1 at 0x60200000029e thread T0                                                                                                           \r\n    #0 0x7f800af7095c in bfd_getl32 \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/libbfd.c:559:24                                       \r\n    #1 0x7f800af91323 in bfd_get_debug_link_info_1 \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/opncls.c:1206:12                       \r\n    #2 0x7f800af91b8a in find_separate_debug_file \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/opncls.c:1423:10                        \r\n    #3 0x7f800af91a0f in bfd_follow_gnu_debuglink \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/opncls.c:1582:10                        \r\n    #4 0x7f800b110614 in _bfd_dwarf2_slurp_debug_info \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/dwarf2.c:4345:19                    \r\n    #5 0x7f800b11bc67 in _bfd_dwarf2_find_nearest_line \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/dwarf2.c:4538:9                    \r\n    #6 0x7f800b05e38b in _bfd_elf_find_line \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/elf.c:8695:10                                 \r\n    #7 0x517c83 in print_symbol \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1003:9                                          \r\n    #8 0x51542d in print_symbols \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1084:7                                         \r\n    #9 0x51542d in display_rel_file \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1200                                        \r\n    #10 0x510f56 in display_file \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1318:7                                         \r\n    #11 0x50faae in main \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1792:12                                                \r\n    #12 0x7f8009fa3680 in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.23-r4\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289                      \r\n    #13 0x41ac18 in _init (\/usr\/x86_64-pc-linux-gnu\/binutils-bin\/git\/nm+0x41ac18)                                                                    \r\n\r\n0x60200000029e is located 0 bytes to the right of 14-byte region [0x602000000290,0x60200000029e)\r\nallocated by thread T0 here:\r\n    #0 0x4d8e08 in malloc \/var\/tmp\/portage\/sys-libs\/compiler-rt-sanitizers-5.0.0\/work\/compiler-rt-5.0.0.src\/lib\/asan\/asan_malloc_linux.cc:67\r\n    #1 0x7f800af6f3fc in bfd_malloc \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/libbfd.c:193:9\r\n    #2 0x7f800af64b9f in bfd_get_full_section_contents \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/compress.c:248:21\r\n    #3 0x7f800af91230 in bfd_get_debug_link_info_1 \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/opncls.c:1191:8\r\n    #4 0x7f800af91b8a in find_separate_debug_file \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/opncls.c:1423:10\r\n    #5 0x7f800af91a0f in bfd_follow_gnu_debuglink \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/opncls.c:1582:10\r\n    #6 0x7f800b110614 in _bfd_dwarf2_slurp_debug_info \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/dwarf2.c:4345:19\r\n    #7 0x7f800b11bc67 in _bfd_dwarf2_find_nearest_line \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/dwarf2.c:4538:9\r\n    #8 0x7f800b05e38b in _bfd_elf_find_line \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/elf.c:8695:10\r\n    #9 0x517c83 in print_symbol \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1003:9\r\n    #10 0x51542d in print_symbols \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1084:7\r\n    #11 0x51542d in display_rel_file \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1200\r\n    #12 0x510f56 in display_file \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1318:7\r\n    #13 0x50faae in main \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1792:12\r\n    #14 0x7f8009fa3680 in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.23-r4\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/libbfd.c:559:24 in bfd_getl32\r\nShadow bytes around the buggy address:\r\n  0x0c047fff8000: fa fa 00 01 fa fa 00 06 fa fa fd fa fa fa fd fa\r\n  0x0c047fff8010: fa fa fd fd fa fa fd fa fa fa fd fa fa fa fd fa\r\n  0x0c047fff8020: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fa\r\n  0x0c047fff8030: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fa\r\n  0x0c047fff8040: fa fa fd fa fa fa fd fd fa fa fd fa fa fa 00 fa\r\n=&gt;0x0c047fff8050: fa fa 00[06]fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff8090: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff80a0: 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==11994==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n2.29.51.20170924 and maybe past releases<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/sourceware.org\/git\/gitweb.cgi?p=binutils-gdb.git;h=52b36c51e5bf6d7600fdc6ba115b170b0e78e31d\">https:\/\/sourceware.org\/git\/gitweb.cgi?p=binutils-gdb.git;h=52b36c51e5bf6d7600fdc6ba115b170b0e78e31d<\/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-15021<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00373-binutils-heapoverflow-bfd_getl32\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00373-binutils-heapoverflow-bfd_getl32<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-09-24: bug discovered and reported to upstream<br \/>\n2017-09-24: upstream released a patch<br \/>\n2017-10-03: blog post about the issue<br \/>\n2017-10-04: 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>.<br \/>\nThis bug was identified with bare metal servers donated by <a href=\"https:\/\/www.packet.net\/\">Packet<\/a>. This work is also supported by the <a href=\"https:\/\/www.coreinfrastructure.org\">Core<br \/>\nInfrastructure Initiative<\/a>.<\/p>\n<p><strong>Permalink:<\/strong><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"25WONqEg1J\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/10\/03\/binutils-heap-based-buffer-overflow-in-bfd_getl32-opncls-c\/\">binutils: heap-based buffer overflow in bfd_getl32 (opncls.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\/10\/03\/binutils-heap-based-buffer-overflow-in-bfd_getl32-opncls-c\/embed\/#?secret=25WONqEg1J\" data-secret=\"25WONqEg1J\" width=\"600\" height=\"338\" title=\"&#8220;binutils: heap-based buffer overflow in bfd_getl32 (opncls.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: binutils is a set of tools necessary to build programs. The complete ASan output of the issue: # nm -A -a -l -S -s &#8211;special-syms &#8211;synthetic &#8211;with-symbol-versions -D $FILE ==11994==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000029e at pc 0x7f800af7095d bp &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/10\/03\/binutils-heap-based-buffer-overflow-in-bfd_getl32-opncls-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-Bs","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2322"}],"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=2322"}],"version-history":[{"count":5,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2322\/revisions"}],"predecessor-version":[{"id":2341,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2322\/revisions\/2341"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=2322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=2322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=2322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}