{"id":860,"date":"2016-11-07T18:20:50","date_gmt":"2016-11-07T16:20:50","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=860"},"modified":"2016-12-01T15:56:04","modified_gmt":"2016-12-01T13:56:04","slug":"libdwarf-heap-based-buffer-overflow-in-get_attr_value-print_die-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2016\/11\/07\/libdwarf-heap-based-buffer-overflow-in-get_attr_value-print_die-c\/","title":{"rendered":"libdwarf: heap-based buffer overflow in  get_attr_value (print_die.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/www.prevanders.net\/dwarf.html\">libdwarf<\/a> is a library to consume and produce DWARF debug information.<\/p>\n<p>A fuzz on an updated version revealed a buffer overflow.<\/p>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># dwarfdump $FILE\r\n==27395==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61300000de1c at pc 0x000000528cd3 bp 0x7ffd980a63b0 sp 0x7ffd980a63a8\r\nREAD of size 1 at 0x61300000de1c thread T0\r\n    #0 0x528cd2 in get_attr_value \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:4978:21\r\n    #1 0x51e4a4 in print_attribute \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:3357:13\r\n    #2 0x51a651 in print_one_die \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:1458:38\r\n    #3 0x51710c in print_die_and_children_internal \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:1047:36\r\n    #4 0x517c6b in print_die_and_children_internal \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:1142:13\r\n    #5 0x5147cc in print_die_and_children \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:921:5\r\n    #6 0x5147cc in print_one_die_section \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:831\r\n    #7 0x512262 in print_infos \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:371:16\r\n    #8 0x4faafa in process_one_file \/tmp\/dwarf-20161021\/dwarfdump\/dwarfdump.c:1371:9\r\n    #9 0x4faafa in main \/tmp\/dwarf-20161021\/dwarfdump\/dwarfdump.c:654\r\n    #10 0x7f883beec61f in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.22-r4\/work\/glibc-2.22\/csu\/libc-start.c:289\r\n    #11 0x419588 in _start (\/usr\/bin\/dwarfdump-asan+0x419588)\r\n\r\n0x61300000de1c is located 0 bytes to the right of 348-byte region [0x61300000dcc0,0x61300000de1c)\r\nallocated by thread T0 here:\r\n    #0 0x4c0ad8 in malloc \/var\/tmp\/portage\/sys-devel\/llvm-3.8.1-r2\/work\/llvm-3.8.1.src\/projects\/compiler-rt\/lib\/asan\/asan_malloc_linux.cc:52\r\n    #1 0x7f883cfc6206 in __libelf_set_rawdata_wrlock \/tmp\/portage\/dev-libs\/elfutils-0.166\/work\/elfutils-0.166\/libelf\/elf_getdata.c:318\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/tmp\/dwarf-20161021\/dwarfdump\/print_die.c:4978:21 in get_attr_value\r\nShadow bytes around the buggy address:\r\n  0x0c267fff9b70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c267fff9b80: 00 00 00 00 00 00 00 00 00 00 03 fa fa fa fa fa\r\n  0x0c267fff9b90: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00\r\n  0x0c267fff9ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c267fff9bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n=&gt;0x0c267fff9bc0: 00 00 00[04]fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c267fff9bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c267fff9be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c267fff9bf0: 00 00 00 00 00 00 00 00 00 00 00 03 fa fa fa fa\r\n  0x0c267fff9c00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c267fff9c10: 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  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==27395==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n20161021<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\n20161124<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/sourceforge.net\/p\/libdwarf\/code\/ci\/583f8834083b5ef834c497f5b47797e16101a9a6\/\">https:\/\/sourceforge.net\/p\/libdwarf\/code\/ci\/583f8834083b5ef834c497f5b47797e16101a9a6\/<\/a><\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo of Gentoo.<\/p>\n<p><strong>CVE:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00025-libdwarf-heapoverflow-get_attr_value\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00025-libdwarf-heapoverflow-get_attr_value<br \/>\n<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2016-11-02: bug discovered and reported to upstream<br \/>\n2016-11-05: upstream released a patch<br \/>\n2016-11-07: blog post about the issue<br \/>\n2016-11-24: upstream released 20161124<\/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=\"YouJxf01Zt\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2016\/11\/07\/libdwarf-heap-based-buffer-overflow-in-get_attr_value-print_die-c\/\">libdwarf: heap-based buffer overflow in  get_attr_value (print_die.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\/2016\/11\/07\/libdwarf-heap-based-buffer-overflow-in-get_attr_value-print_die-c\/embed\/#?secret=YouJxf01Zt\" data-secret=\"YouJxf01Zt\" width=\"600\" height=\"338\" title=\"&#8220;libdwarf: heap-based buffer overflow in  get_attr_value (print_die.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: libdwarf is a library to consume and produce DWARF debug information. A fuzz on an updated version revealed a buffer overflow. The complete ASan output: # dwarfdump $FILE ==27395==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61300000de1c at pc 0x000000528cd3 bp 0x7ffd980a63b0 &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2016\/11\/07\/libdwarf-heap-based-buffer-overflow-in-get_attr_value-print_die-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-dS","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/860"}],"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=860"}],"version-history":[{"count":5,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/860\/revisions"}],"predecessor-version":[{"id":999,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/860\/revisions\/999"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}