{"id":401,"date":"2016-08-03T10:08:19","date_gmt":"2016-08-03T08:08:19","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=401"},"modified":"2016-12-16T12:31:11","modified_gmt":"2016-12-16T10:31:11","slug":"logrotate-heap-based-buffer-overflow-in-readconfigfile-config-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2016\/08\/03\/logrotate-heap-based-buffer-overflow-in-readconfigfile-config-c\/","title":{"rendered":"logrotate: heap-based buffer overflow in readConfigFile (config.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/github.com\/logrotate\/logrotate\">logrotate<\/a> allows for the automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file daily, weekly, monthly or when the log file gets to a certain size.<\/p>\n<p>A crafted config causes an out-of-bounds read in readConfigFile.<br \/>\nThe complete ASan output:<\/p>\n<pre><font size=\"2\">logrotate -d $crafted_file\r\n=================================================================\r\n==809==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000df8f at pc 0x00000050b244 bp 0x7ffd4cab50f0 sp 0x7ffd4cab50e8\r\nREAD of size 1 at 0x60200000df8f thread T0\r\n    #0 0x50b243 in readConfigFile \/tmp\/portage\/app-admin\/logrotate-3.9.2\/work\/logrotate-3.9.2\/config.c:969:11\r\n    #1 0x4fa61b in readConfigPath \/tmp\/portage\/app-admin\/logrotate-3.9.2\/work\/logrotate-3.9.2\/config.c:578:6\r\n    #2 0x4f99a7 in readAllConfigPaths \/tmp\/portage\/app-admin\/logrotate-3.9.2\/work\/logrotate-3.9.2\/config.c:645:6\r\n    #3 0x4f193e in main \/tmp\/portage\/app-admin\/logrotate-3.9.2\/work\/logrotate-3.9.2\/logrotate.c:2554:6\r\n    #4 0x7f37cad0662f in __libc_start_main (\/lib64\/libc.so.6+0x2062f)\r\n    #5 0x436988 in _start (\/usr\/sbin\/logrotate+0x436988)\r\n\r\n0x60200000df8f is located 1 bytes to the left of 1-byte region [0x60200000df90,0x60200000df91)\r\nallocated by thread T0 here:\r\n    #0 0x4bd952 in __interceptor_malloc (\/usr\/sbin\/logrotate+0x4bd952)\r\n    #1 0x7f37cad67359 in strndup (\/lib64\/libc.so.6+0x81359)\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/tmp\/portage\/app-admin\/logrotate-3.9.2\/work\/logrotate-3.9.2\/config.c:969 readConfigFile\r\nShadow bytes around the buggy address:\r\n  0x0c047fff9ba0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9bb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9bc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9bd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c047fff9be0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n=&gt;0x0c047fff9bf0: fa[fa]01 fa fa fa 00 fa fa fa fd fd fa fa fd fa\r\n  0x0c047fff9c00: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa\r\n  0x0c047fff9c10: fa fa fd fa fa fa fd fd fa fa fd fd fa fa fd fa\r\n  0x0c047fff9c20: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa\r\n  0x0c047fff9c30: fa fa fd fd fa fa fd fa fa fa fd fd fa fa fd fa\r\n  0x0c047fff9c40: fa fa fd fd fa fa fd fa fa fa fd fa fa fa fd 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==809==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n3.9.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\/logrotate\/logrotate\/commit\/f53ed9c968fe92ba6e50b9b394a891350503469f\">https:\/\/github.com\/logrotate\/logrotate\/commit\/f53ed9c968fe92ba6e50b9b394a891350503469f<\/a><\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo of Gentoo.<\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2016-05-05: bug discovered<br \/>\n2016-05-06: bug reported to upstream (github)<br \/>\n2016-08-03: no upstream response<br \/>\n2016-08-03: blog post about the issue<br \/>\n2016-12-12: upstream added a patch<\/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=\"A7RlZ4eADP\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2016\/08\/03\/logrotate-heap-based-buffer-overflow-in-readconfigfile-config-c\/\">logrotate: heap-based buffer overflow in readConfigFile (config.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\/08\/03\/logrotate-heap-based-buffer-overflow-in-readconfigfile-config-c\/embed\/#?secret=A7RlZ4eADP\" data-secret=\"A7RlZ4eADP\" width=\"600\" height=\"338\" title=\"&#8220;logrotate: heap-based buffer overflow in readConfigFile (config.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: logrotate allows for the automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file daily, weekly, monthly or when the log file gets to a certain size. A crafted config causes &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2016\/08\/03\/logrotate-heap-based-buffer-overflow-in-readconfigfile-config-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-6t","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/401"}],"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=401"}],"version-history":[{"count":3,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":1050,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/401\/revisions\/1050"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}