{"id":2130,"date":"2017-09-06T16:03:13","date_gmt":"2017-09-06T14:03:13","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=2130"},"modified":"2017-09-06T20:52:58","modified_gmt":"2017-09-06T18:52:58","slug":"libarchive-heap-based-buffer-overflow-in-xml_data-archive_read_support_format_xar-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/09\/06\/libarchive-heap-based-buffer-overflow-in-xml_data-archive_read_support_format_xar-c\/","title":{"rendered":"libarchive: heap-based buffer overflow in xml_data (archive_read_support_format_xar.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"http:\/\/www.libarchive.org\/\">libarchive<\/a> is a multi-format archive and compression library.<\/p>\n<p>The complete ASan output of the issue:<\/p>\n<pre><font size=\"2\"># bsdtar -t -f $FILE\r\n==13144==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x631000038800 at pc 0x7fb1c808f650 bp 0x7ffdd1b40990 sp 0x7ffdd1b40988            \r\nREAD of size 1 at 0x631000038800 thread T0                                                                                                           \r\n    #0 0x7fb1c808f64f in xml_data \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/libarchive\/archive_read_support_format_xar.c      \r\n    #1 0x7fb1c808f64f in expat_data_cb \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/libarchive\/archive_read_support_format_xar.c:3230                                                                                                                                                 \r\n    #2 0x7fb1c697c3b6 in _init \/var\/tmp\/portage\/dev-libs\/expat-2.2.1\/work\/expat-2.2.1\/lib\/xmlparse.c:2960                                            \r\n    #3 0x7fb1c697cb9b in _init \/var\/tmp\/portage\/dev-libs\/expat-2.2.1\/work\/expat-2.2.1\/lib\/xmlparse.c:2418                                            \r\n    #4 0x7fb1c697e988 in _init \/var\/tmp\/portage\/dev-libs\/expat-2.2.1\/work\/expat-2.2.1\/lib\/xmlparse.c:4366                                            \r\n    #5 0x7fb1c697f137 in _init \/var\/tmp\/portage\/dev-libs\/expat-2.2.1\/work\/expat-2.2.1\/lib\/xmlparse.c:4089                                            \r\n    #6 0x7fb1c6980fc7 in XML_ParseBuffer \/var\/tmp\/portage\/dev-libs\/expat-2.2.1\/work\/expat-2.2.1\/lib\/xmlparse.c:1915                                  \r\n    #7 0x7fb1c807d62a in expat_read_toc \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/libarchive\/archive_read_support_format_xar.c:3273:8                                                                                                                                              \r\n    #8 0x7fb1c807d62a in read_toc \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/libarchive\/archive_read_support_format_xar.c:584  \r\n    #9 0x7fb1c807d62a in xar_read_header \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/libarchive\/archive_read_support_format_xar.c:677                                                                                                                                                \r\n    #10 0x7fb1c7f728ed in _archive_read_next_header2 \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/libarchive\/archive_read.c:648:7\r\n    #11 0x7fb1c7f72590 in _archive_read_next_header \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/libarchive\/archive_read.c:686:8 \r\n    #12 0x51483f in read_archive \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/tar\/read.c:260:7\r\n    #13 0x513d89 in tar_mode_t \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/tar\/read.c:94:2\r\n    #14 0x50eaae in main \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/tar\/bsdtar.c:858:3\r\n    #15 0x7fb1c6ffe680 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    #16 0x41c628 in _init (\/usr\/bin\/bsdtar+0x41c628)\r\n\r\n0x631000038800 is located 0 bytes to the right of 65536-byte region [0x631000028800,0x631000038800)\r\nallocated by thread T0 here:\r\n    #0 0x4d1fd8 in malloc \/var\/tmp\/portage\/sys-libs\/compiler-rt-sanitizers-4.0.1\/work\/compiler-rt-4.0.1.src\/lib\/asan\/asan_malloc_linux.cc:66\r\n    #1 0x7fb1c69811f5 in XML_GetBuffer \/var\/tmp\/portage\/dev-libs\/expat-2.2.1\/work\/expat-2.2.1\/lib\/xmlparse.c:2004\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/var\/tmp\/portage\/app-arch\/libarchive-3.3.2\/work\/libarchive-3.3.2\/libarchive\/archive_read_support_format_xar.c in xml_data\r\nShadow bytes around the buggy address:\r\n  0x0c627ffff0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c627ffff0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c627ffff0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c627ffff0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c627ffff0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n=&gt;0x0c627ffff100:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c627ffff110: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c627ffff120: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c627ffff130: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c627ffff140: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c627ffff150: 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==13144==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n3.3.2<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/libarchive\/libarchive\/commit\/fa7438a0ff4033e4741c807394a9af6207940d71\">https:\/\/github.com\/libarchive\/libarchive\/commit\/fa7438a0ff4033e4741c807394a9af6207940d71<\/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-14166<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00316-libarchive-heapoverflow-archive_read_support_format_xar\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00316-libarchive-heapoverflow-archive_read_support_format_xar<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-08-15: bug discovered and reported to upstream<br \/>\n2017-09-05: upstream released a patch<br \/>\n2017-09-06: blog post about the issue<br \/>\n2017-09-06: 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 Infrastructure Initiative<\/a>.<\/p>\n<p><strong>Permalink:<\/strong><\/p>\n<blockquote data-secret=\"UwwjdNpx8P\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/09\/06\/libarchive-heap-based-buffer-overflow-in-xml_data-archive_read_support_format_xar-c\/\">libarchive: heap-based buffer overflow in xml_data (archive_read_support_format_xar.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\/09\/06\/libarchive-heap-based-buffer-overflow-in-xml_data-archive_read_support_format_xar-c\/embed\/#?secret=UwwjdNpx8P\" data-secret=\"UwwjdNpx8P\" width=\"600\" height=\"338\" title=\"&#8220;libarchive: heap-based buffer overflow in xml_data (archive_read_support_format_xar.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: libarchive is a multi-format archive and compression library. The complete ASan output of the issue: # bsdtar -t -f $FILE ==13144==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x631000038800 at pc 0x7fb1c808f650 bp 0x7ffdd1b40990 sp 0x7ffdd1b40988 READ of size 1 at 0x631000038800 &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/09\/06\/libarchive-heap-based-buffer-overflow-in-xml_data-archive_read_support_format_xar-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-ym","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2130"}],"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=2130"}],"version-history":[{"count":4,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2130\/revisions"}],"predecessor-version":[{"id":2137,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2130\/revisions\/2137"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=2130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=2130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=2130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}