{"id":1591,"date":"2017-04-03T18:22:52","date_gmt":"2017-04-03T16:22:52","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1591"},"modified":"2017-04-10T09:35:40","modified_gmt":"2017-04-10T07:35:40","slug":"elfutils-heap-based-buffer-overflow-in-check_symtab_shndx-elflint-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/04\/03\/elfutils-heap-based-buffer-overflow-in-check_symtab_shndx-elflint-c\/","title":{"rendered":"elfutils: heap-based buffer overflow in check_symtab_shndx (elflint.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/sourceware.org\/elfutils\/\">elfutils<\/a> is a set of libraries\/utilities to handle ELF objects (drop in replacement for libelf).<\/p>\n<p>A fuzz on eu-elflint showed an heap overflow.<\/p>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># eu-elflint -d $FILE\r\n==14342==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000efd0 at pc 0x0000004267ec bp 0x7ffdf36a7ad0 sp 0x7ffdf36a7ac8\r\nREAD of size 4 at 0x60200000efd0 thread T0\r\n    #0 0x4267eb in check_symtab_shndx \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:1961\r\n    #1 0x4267eb in check_sections \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:4114\r\n    #2 0x42961f in process_elf_file \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:4697\r\n    #3 0x42961f in process_file \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:242\r\n    #4 0x402d33 in main \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:175\r\n    #5 0x7f625ef4678f in __libc_start_main (\/lib64\/libc.so.6+0x2078f)\r\n    #6 0x403498 in _start (\/usr\/bin\/eu-elflint+0x403498)\r\n\r\n0x60200000efd2 is located 0 bytes to the right of 2-byte region [0x60200000efd0,0x60200000efd2)\r\nallocated by thread T0 here:\r\n    #0 0x7f6260633288 in malloc (\/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/6.3.0\/libasan.so.3+0xc2288)\r\n    #1 0x7f626028fb46 in convert_data \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/libelf\/elf_getdata.c:166\r\n    #2 0x7f626028fb46 in __libelf_set_data_list_rdlock \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/libelf\/elf_getdata.c:434\r\n    #3 0x7f6260290662 in __elf_getdata_rdlock \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/libelf\/elf_getdata.c:541\r\n    #4 0x7f6260290776 in elf_getdata \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/libelf\/elf_getdata.c:559\r\n    #5 0x7f62602bc035 in elf32_getchdr \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/libelf\/elf32_getchdr.c:72\r\n    #6 0x7f62602bc55c in gelf_getchdr \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/libelf\/gelf_getchdr.c:52\r\n    #7 0x420edf in check_sections \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:3911\r\n    #8 0x42961f in process_elf_file \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:4697\r\n    #9 0x42961f in process_file \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:242\r\n    #10 0x402d33 in main \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:175\r\n    #11 0x7f625ef4678f in __libc_start_main (\/lib64\/libc.so.6+0x2078f)\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:1961 in check_symtab_shndx\r\nShadow bytes around the buggy address:\r\n  0x0c047fff9da0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9db0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9dc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9dd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9de0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n=&gt;0x0c047fff9df0: fa fa fa fa fa fa fa fa fa fa[02]fa fa fa 00 01\r\n  0x0c047fff9e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9e30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9e40: 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==14342==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n0.168<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\n0.169 (not released atm)<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/sourceware.org\/ml\/elfutils-devel\/2017-q1\/msg00129.html\">https:\/\/sourceware.org\/ml\/elfutils-devel\/2017-q1\/msg00129.html<\/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-7611<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00234-elfutils-heapoverflow-check_symtab_shndx\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00234-elfutils-heapoverflow-check_symtab_shndx<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-03-27: bug discovered and reported to upstream<br \/>\n2017-04-04: blog post about the issue<br \/>\n2017-04-09: 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=\"W7TPVjlaLQ\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/04\/03\/elfutils-heap-based-buffer-overflow-in-check_symtab_shndx-elflint-c\/\">elfutils: heap-based buffer overflow in check_symtab_shndx (elflint.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\/03\/elfutils-heap-based-buffer-overflow-in-check_symtab_shndx-elflint-c\/embed\/#?secret=W7TPVjlaLQ\" data-secret=\"W7TPVjlaLQ\" width=\"600\" height=\"338\" title=\"&#8220;elfutils: heap-based buffer overflow in check_symtab_shndx (elflint.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: elfutils is a set of libraries\/utilities to handle ELF objects (drop in replacement for libelf). A fuzz on eu-elflint showed an heap overflow. The complete ASan output: # eu-elflint -d $FILE ==14342==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000efd0 at pc &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/04\/03\/elfutils-heap-based-buffer-overflow-in-check_symtab_shndx-elflint-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-pF","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1591"}],"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=1591"}],"version-history":[{"count":2,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1591\/revisions"}],"predecessor-version":[{"id":1622,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1591\/revisions\/1622"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}