{"id":365,"date":"2016-07-28T10:38:26","date_gmt":"2016-07-28T08:38:26","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=365"},"modified":"2016-09-07T14:36:14","modified_gmt":"2016-09-07T12:36:14","slug":"paps-heap-based-buffer-overflow-in-read_file-paps-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2016\/07\/28\/paps-heap-based-buffer-overflow-in-read_file-paps-c\/","title":{"rendered":"paps: heap-based buffer overflow in read_file() (paps.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/sourceforge.net\/projects\/paps\/\">Paps<\/a> is an UTF-8 to PostScript converter that makes use of pango. It provides both a stand alone command line tool as well as a library<\/p>\n<p>It was discovered that a crafted\/empty file is able to cause an heap-based buffer overflow.<br \/>\nApparently, the project does not have release(s) since 2007 and seems to be dead, but I just discovered right now that the project has moved <strong>silently<\/strong> to github where the PR has been sent.<\/p>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># paps $crafted.file\r\n=================================================================                                                                                                                                                                                                              \r\n==30527==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000dfaf at pc 0x0000004e122d bp 0x7ffd8f3dfe90 sp 0x7ffd8f3dfe88                                                                                                                                      \r\nREAD of size 1 at 0x60200000dfaf thread T0                                                                                                                                                                                                                                     \r\n    #0 0x4e122c in read_file \/tmp\/portage\/app-text\/paps-0.6.8-r1\/work\/paps-0.6.8\/src\/paps.c:573:7                                                                                                                                                                              \r\n    #1 0x4e122c in main \/tmp\/portage\/app-text\/paps-0.6.8-r1\/work\/paps-0.6.8\/src\/paps.c:493                                                                                                                                                                                     \r\n    #2 0x7fd8aff707af in __libc_start_main (\/lib64\/libc.so.6+0x207af)                                                                                                                                                                                                          \r\n    #3 0x436968 in _start (\/usr\/bin\/paps+0x436968)                                                                                                                                                                                                                             \r\n                                                                                                                                                                                                                                                                               \r\n0x60200000dfaf is located 1 bytes to the left of 4-byte region [0x60200000dfb0,0x60200000dfb4)                                                                                                                                                                                 \r\nallocated by thread T0 here:                                                                                                                                                                                                                                                   \r\n    #0 0x4bdc75 in realloc (\/usr\/bin\/paps+0x4bdc75)                                                                                                                                                                                                                            \r\n    #1 0x7fd8b111c35d in g_realloc (\/usr\/lib64\/libglib-2.0.so.0+0x4e35d)                                                                                                                                                                                                       \r\n                                                                                                                                                                                                                                                                               \r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/tmp\/portage\/app-text\/paps-0.6.8-r1\/work\/paps-0.6.8\/src\/paps.c:573 read_file                                                                                                                                                   \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 fa fa fa[fa]04 fa fa fa 00 02 fa fa 00 02                                                                                                                                                                                                              \r\n  0x0c047fff9c00: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fa                                                                                                                                                                                                              \r\n  0x0c047fff9c10: fa fa fd fa fa fa 00 00 fa fa 00 00 fa fa 00 00                                                                                                                                                                                                              \r\n  0x0c047fff9c20: fa fa 00 00 fa fa 00 fa fa fa 00 00 fa fa fd fa                                                                                                                                                                                                              \r\n  0x0c047fff9c30: fa fa fd fa fa fa fd fa fa fa 00 00 fa fa 00 00                                                                                                                                                                                                              \r\n  0x0c047fff9c40: fa fa 00 fa fa fa 00 00 fa fa 00 00 fa fa 00 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==30527==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\nAll versions.<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\n0.6.8-r2 (in Gentoo)<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\nhttps:\/\/gitweb.gentoo.org\/repo\/gentoo.git\/tree\/app-text\/paps\/files\/paps-0.6.8-fix-empty-file.patch<\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo of Gentoo.<br \/>\nThis bug was fixed by Jason A. Donenfeld of Gentoo.<\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2015-06-09: bug discovered<br \/>\n2015-11-17: bug reported downstream (Gentoo)<br \/>\n2016-07-12: fixed produced downstream<br \/>\n2016-07-28: blog post about the issue<\/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=\"YHP2Uz2dNo\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2016\/07\/28\/paps-heap-based-buffer-overflow-in-read_file-paps-c\/\">paps: heap-based buffer overflow in read_file() (paps.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\/07\/28\/paps-heap-based-buffer-overflow-in-read_file-paps-c\/embed\/#?secret=YHP2Uz2dNo\" data-secret=\"YHP2Uz2dNo\" width=\"600\" height=\"338\" title=\"&#8220;paps: heap-based buffer overflow in read_file() (paps.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: Paps is an UTF-8 to PostScript converter that makes use of pango. It provides both a stand alone command line tool as well as a library It was discovered that a crafted\/empty file is able to cause an heap-based &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2016\/07\/28\/paps-heap-based-buffer-overflow-in-read_file-paps-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-5T","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/365"}],"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=365"}],"version-history":[{"count":7,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/365\/revisions"}],"predecessor-version":[{"id":392,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/365\/revisions\/392"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}