{"id":1320,"date":"2017-03-02T18:24:24","date_gmt":"2017-03-02T16:24:24","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1320"},"modified":"2017-03-13T11:58:44","modified_gmt":"2017-03-13T09:58:44","slug":"podofo-heap-based-buffer-overflow-in-podofopdfvariantdelayedload-pdfvariant-h","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/03\/02\/podofo-heap-based-buffer-overflow-in-podofopdfvariantdelayedload-pdfvariant-h\/","title":{"rendered":"podofo: heap-based buffer overflow in PoDoFo::PdfVariant::DelayedLoad (PdfVariant.h)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/sourceforge.net\/projects\/podofo\/\">podofo<\/a> is a C++ library to work with the PDF file format.<\/p>\n<p>A fuzz on it discovered an heap overflow. The upstream project denies me to open a new ticket. So, I just will forward this on the -users mailing list.<\/p>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># podofocolor dummy $FILE foo\r\n==5749==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62500000a0f8 at pc 0x000000529e84 bp 0x7ffee90e1ad0 sp 0x7ffee90e1ac8\r\nREAD of size 1 at 0x62500000a0f8 thread T0\r\n    #0 0x529e83 in PoDoFo::PdfVariant::DelayedLoad() const \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/podofo\/base\/..\/..\/src\/base\/PdfVariant.h:545:10\r\n    #1 0x529e83 in PoDoFo::PdfVariant::GetReal() const \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/podofo\/base\/..\/..\/src\/base\/PdfVariant.h:675\r\n    #2 0x52887e in ColorChanger::GetColorFromStack(int, std::vector&lt;PoDoFo::PdfVariant, std::allocator &gt;&amp;) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/colorchanger.cpp:423:33\r\n    #3 0x525d4b in ColorChanger::ProcessColor(ColorChanger::EKeywordType, int, std::vector&lt;PoDoFo::PdfVariant, std::allocator &gt;&amp;, GraphicsStack&amp;) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/colorchanger.cpp:449:28\r\n    #4 0x521b3c in ColorChanger::ReplaceColorsInPage(PoDoFo::PdfCanvas*) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/colorchanger.cpp:214:31\r\n    #5 0x51ed8e in ColorChanger::start() \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/colorchanger.cpp:120:15\r\n    #6 0x51c06d in main \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/podofocolor.cpp:116:12\r\n    #7 0x7f6c2623561f in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.22-r4\/work\/glibc-2.22\/csu\/libc-start.c:289\r\n    #8 0x428718 in _start (\/usr\/bin\/podofocolor+0x428718)\r\n\r\n0x62500000a0f8 is located 8 bytes to the left of 8192-byte region [0x62500000a100,0x62500000c100)\r\nallocated by thread T0 here:\r\n    #0 0x518700 in operator new(unsigned long) \/tmp\/portage\/sys-devel\/llvm-3.9.0-r1\/work\/llvm-3.9.0.src\/projects\/compiler-rt\/lib\/asan\/asan_new_delete.cc:78\r\n    #1 0x52aa18 in __gnu_cxx::new_allocator::allocate(unsigned long, void const*) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/ext\/new_allocator.h:104:27\r\n    #2 0x52aa18 in __gnu_cxx::__alloc_traits&lt;std::allocator &gt;::allocate(std::allocator&amp;, unsigned long) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/ext\/alloc_traits.h:182\r\n    #3 0x52aa18 in std::_Vector_base&lt;PoDoFo::PdfVariant, std::allocator &gt;::_M_allocate(unsigned long) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/stl_vector.h:170\r\n    #4 0x52aa18 in std::vector&lt;PoDoFo::PdfVariant, std::allocator &gt;::_M_insert_aux(__gnu_cxx::__normal_iterator&lt;PoDoFo::PdfVariant*, std::vector&lt;PoDoFo::PdfVariant, std::allocator &gt; &gt;, PoDoFo::PdfVariant const&amp;) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/vector.tcc:353\r\n    #5 0x521bdd in std::vector&lt;PoDoFo::PdfVariant, std::allocator &gt;::push_back(PoDoFo::PdfVariant const&amp;) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/stl_vector.h:925:4\r\n    #6 0x521bdd in ColorChanger::ReplaceColorsInPage(PoDoFo::PdfCanvas*) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/colorchanger.cpp:170\r\n    #7 0x51ed8e in ColorChanger::start() \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/colorchanger.cpp:120:15\r\n    #8 0x51c06d in main \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/podofocolor.cpp:116:12\r\n    #9 0x7f6c2623561f in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.22-r4\/work\/glibc-2.22\/csu\/libc-start.c:289\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/podofo\/base\/..\/..\/src\/base\/PdfVariant.h:545:10 in PoDoFo::PdfVariant::DelayedLoad() const\r\nShadow bytes around the buggy address:\r\n  0x0c4a7fff93c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c4a7fff93d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c4a7fff93e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c4a7fff93f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n  0x0c4a7fff9400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa\r\n=&gt;0x0c4a7fff9410: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]\r\n  0x0c4a7fff9420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c4a7fff9430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c4a7fff9440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c4a7fff9450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x0c4a7fff9460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\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==5749==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n0.9.4<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\nN\/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-6843<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00170-podofo-heapoverflow-PoDoFo-PdfTokenizer-GetNextToken\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00170-podofo-heapoverflow-PoDoFo-PdfTokenizer-GetNextToken<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-02-13: bug discovered<br \/>\n2017-03-02: bug reported to upstream<br \/>\n2017-03-02: blog post about the issue<br \/>\n2017-03-12: 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=\"lpF8y1yrbi\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/03\/02\/podofo-heap-based-buffer-overflow-in-podofopdfvariantdelayedload-pdfvariant-h\/\">podofo: heap-based buffer overflow in PoDoFo::PdfVariant::DelayedLoad (PdfVariant.h)<\/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\/03\/02\/podofo-heap-based-buffer-overflow-in-podofopdfvariantdelayedload-pdfvariant-h\/embed\/#?secret=lpF8y1yrbi\" data-secret=\"lpF8y1yrbi\" width=\"600\" height=\"338\" title=\"&#8220;podofo: heap-based buffer overflow in PoDoFo::PdfVariant::DelayedLoad (PdfVariant.h)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: podofo is a C++ library to work with the PDF file format. A fuzz on it discovered an heap overflow. The upstream project denies me to open a new ticket. So, I just will forward this on the -users &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/03\/02\/podofo-heap-based-buffer-overflow-in-podofopdfvariantdelayedload-pdfvariant-h\/\">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-li","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1320"}],"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=1320"}],"version-history":[{"count":5,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1320\/revisions"}],"predecessor-version":[{"id":1454,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1320\/revisions\/1454"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}