{"id":1323,"date":"2017-03-02T18:24:27","date_gmt":"2017-03-02T16:24:27","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1323"},"modified":"2017-03-13T11:59:16","modified_gmt":"2017-03-13T09:59:16","slug":"podofo-global-buffer-overflow-in-podofopdfparserreadxrefsubsection-pdfparser-cpp","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/03\/02\/podofo-global-buffer-overflow-in-podofopdfparserreadxrefsubsection-pdfparser-cpp\/","title":{"rendered":"podofo: global buffer overflow in PoDoFo::PdfParser::ReadXRefSubsection (PdfParser.cpp)"},"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 a global 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==15599==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000014a5838 at pc 0x0000004ca58c bp 0x7ffebe3248b0 sp 0x7ffebe324060\r\nWRITE of size 24 at 0x0000014a5838 thread T0\r\n    #0 0x4ca58b in __asan_memcpy \/tmp\/portage\/sys-devel\/llvm-3.9.0-r1\/work\/llvm-3.9.0.src\/projects\/compiler-rt\/lib\/asan\/asan_interceptors.cc:413\r\n    #1 0x7efe75862464 in void std::_Construct(PoDoFo::PdfParser::TXRefEntry*, PoDoFo::PdfParser::TXRefEntry const&amp;) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/stl_construct.h:83:38\r\n    #2 0x7efe75862464 in void std::__uninitialized_fill_n::__uninit_fill_n(PoDoFo::PdfParser::TXRefEntry*, unsigned long, PoDoFo::PdfParser::TXRefEntry const&amp;) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/stl_uninitialized.h:202\r\n    #3 0x7efe75862464 in void std::uninitialized_fill_n(PoDoFo::PdfParser::TXRefEntry*, unsigned long, PoDoFo::PdfParser::TXRefEntry const&amp;) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/stl_uninitialized.h:244\r\n    #4 0x7efe75862464 in void std::__uninitialized_fill_n_a(PoDoFo::PdfParser::TXRefEntry*, unsigned long, PoDoFo::PdfParser::TXRefEntry const&amp;, std::allocator&amp;) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/stl_uninitialized.h:355\r\n    #5 0x7efe75862464 in std::vector&lt;PoDoFo::PdfParser::TXRefEntry, std::allocator &gt;::_M_fill_insert(__gnu_cxx::__normal_iterator&lt;PoDoFo::PdfParser::TXRefEntry*, std::vector&lt;PoDoFo::PdfParser::TXRefEntry, std::allocator &gt; &gt;, unsigned long, PoDoFo::PdfParser::TXRefEntry const&amp;) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/vector.tcc:496\r\n    #6 0x7efe75855a47 in std::vector&lt;PoDoFo::PdfParser::TXRefEntry, std::allocator &gt;::insert(__gnu_cxx::__normal_iterator&lt;PoDoFo::PdfParser::TXRefEntry*, std::vector&lt;PoDoFo::PdfParser::TXRefEntry, std::allocator &gt; &gt;, unsigned long, PoDoFo::PdfParser::TXRefEntry const&amp;) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/stl_vector.h:1073:9\r\n    #7 0x7efe75855a47 in std::vector&lt;PoDoFo::PdfParser::TXRefEntry, std::allocator &gt;::resize(unsigned long, PoDoFo::PdfParser::TXRefEntry) \/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/4.9.3\/include\/g++-v4\/bits\/stl_vector.h:716\r\n    #8 0x7efe75855a47 in PoDoFo::PdfParser::ReadXRefSubsection(long&amp;, long&amp;) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/src\/base\/PdfParser.cpp:772\r\n    #9 0x7efe758470ad in PoDoFo::PdfParser::ReadXRefContents(long, bool) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/src\/base\/PdfParser.cpp:725:17\r\n    #10 0x7efe75840a9e in PoDoFo::PdfParser::ReadDocumentStructure() \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/src\/base\/PdfParser.cpp:337:9\r\n    #11 0x7efe7583de0f in PoDoFo::PdfParser::ParseFile(PoDoFo::PdfRefCountedInputDevice const&amp;, bool) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/src\/base\/PdfParser.cpp:220:9\r\n    #12 0x7efe7583c1d4 in PoDoFo::PdfParser::ParseFile(char const*, bool) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/src\/base\/PdfParser.cpp:164:11\r\n    #13 0x7efe75a993f3 in PoDoFo::PdfMemDocument::Load(char const*) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/src\/doc\/PdfMemDocument.cpp:186:16\r\n    #14 0x7efe75a990c2 in PoDoFo::PdfMemDocument::PdfMemDocument(char const*) \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/src\/doc\/PdfMemDocument.cpp:88:11\r\n    #15 0x51e96d in ColorChanger::start() \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/colorchanger.cpp:110:20\r\n    #16 0x51c06d in main \/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/tools\/podofocolor\/podofocolor.cpp:116:12\r\n    #17 0x7efe7424861f in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.22-r4\/work\/glibc-2.22\/csu\/libc-start.c:289\r\n    #18 0x428718 in _start (\/usr\/bin\/podofocolor+0x428718)\r\n\r\n0x0000014a5838 is located 0 bytes to the right of global variable 'PoDoFo::PODOFO_BUILTIN_FONTS' defined in '\/tmp\/portage\/app-text\/podofo-0.9.4\/work\/podofo-0.9.4\/src\/doc\/PdfFontFactoryBase14Data.h:4460:33' (0x14a4aa0) of size 3480\r\nSUMMARY: AddressSanitizer: global-buffer-overflow \/tmp\/portage\/sys-devel\/llvm-3.9.0-r1\/work\/llvm-3.9.0.src\/projects\/compiler-rt\/lib\/asan\/asan_interceptors.cc:413 in __asan_memcpy\r\nShadow bytes around the buggy address:\r\n  0x00008028cab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x00008028cac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x00008028cad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x00008028cae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n  0x00008028caf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\r\n=&gt;0x00008028cb00: 00 00 00 00 00 00 00[f9]f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x00008028cb10: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x00008028cb20: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x00008028cb30: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x00008028cb40: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\r\n  0x00008028cb50: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9\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==15599==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-6844<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00171-podofo-globaloverflow-PoDoFo-PdfParser-ReadXRefSubsection\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00171-podofo-globaloverflow-PoDoFo-PdfParser-ReadXRefSubsection<\/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=\"sLWR94hX87\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/03\/02\/podofo-global-buffer-overflow-in-podofopdfparserreadxrefsubsection-pdfparser-cpp\/\">podofo: global buffer overflow in PoDoFo::PdfParser::ReadXRefSubsection (PdfParser.cpp)<\/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-global-buffer-overflow-in-podofopdfparserreadxrefsubsection-pdfparser-cpp\/embed\/#?secret=sLWR94hX87\" data-secret=\"sLWR94hX87\" width=\"600\" height=\"338\" title=\"&#8220;podofo: global buffer overflow in PoDoFo::PdfParser::ReadXRefSubsection (PdfParser.cpp)&#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 a global 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-global-buffer-overflow-in-podofopdfparserreadxrefsubsection-pdfparser-cpp\/\">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-ll","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1323"}],"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=1323"}],"version-history":[{"count":4,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1323\/revisions"}],"predecessor-version":[{"id":1455,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1323\/revisions\/1455"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}