{"id":1961,"date":"2017-08-09T20:02:57","date_gmt":"2017-08-09T18:02:57","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1961"},"modified":"2017-08-17T21:59:47","modified_gmt":"2017-08-17T19:59:47","slug":"libfpx-divide-by-zero-in-cdirvectorgettable-dirfunc-hxx","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/08\/09\/libfpx-divide-by-zero-in-cdirvectorgettable-dirfunc-hxx\/","title":{"rendered":"libfpx: divide-by-zero in CDirVector::GetTable (dirfunc.hxx)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"http:\/\/www.i3a.org\/\">libfpx<\/a> is a library for manipulating FlashPIX images.<\/p>\n<p>I&#8217;m aware that the link to the upstream website does not work. I&#8217;m keeping it as well because in the future the upstream website could appear again.<br \/>\nLibfpx is not actively developed, I contacted the imagemagick project if they were available to patch security issues, but they said the they are only accepting patches and push new releases.<br \/>\nThis issue was found using the gm command line tool of graphicsmagick.<\/p>\n<p>The complete ASan output of the issue:<\/p>\n<pre><font size=\"2\"># gm identify $FILE\r\n==11203==ERROR: AddressSanitizer: FPE on unknown address 0x7fc9f8a8a403 (pc 0x7fc9f8a8a403 bp 0x7fffbf287b28 sp 0x7fffbf287ae0 T0)\r\n    #0 0x7fc9f8a8a402 in CDirVector::GetTable(unsigned int, unsigned int, CDirSect**) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/h\/dirfunc.hxx:250\r\n    #1 0x7fc9f8a8a402 in CDirectory::GetDirEntry(unsigned int, unsigned int, CDirEntry**) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/dir.cxx:1102\r\n    #2 0x7fc9f8a91cff in CDirectory::GetSize(unsigned int, unsigned int*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/h\/dirfunc.hxx:316\r\n    #3 0x7fc9f8a91cff in CMStream::Init() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/mstream.cxx:431\r\n    #4 0x7fc9f8a912e7 in DllMultiStreamFromStream(CMStream**, ILockBytes**, unsigned int) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/msf.cxx:88\r\n    #5 0x7fc9f8a9388b in CRootExposedDocFile::InitRoot(ILockBytes*, unsigned int, unsigned short, unsigned short**) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/rexpdf.cxx:124\r\n    #6 0x7fc9f8a8bad6 in DfFromLB(ILockBytes*, unsigned short, unsigned int, unsigned short**, CExposedDocFile**, _XGUID*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/docfile.cxx:66\r\n    #7 0x7fc9f8a8bdfc in DfOpenStorageOnILockBytesW(ILockBytes*, IStorage*, unsigned int, unsigned short**, unsigned int, IStorage**, _XGUID*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/docfile.cxx:277\r\n    #8 0x7fc9f8a88878 in DfOpenStorageOnILockBytes(ILockBytes*, IStorage*, unsigned int, char**, unsigned int, IStorage**, _XGUID*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/ascii.cxx:461\r\n    #9 0x7fc9f8a9458e in StgOpenStorageOnILockBytes \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/storage.cxx:116\r\n    #10 0x7fc9f8a9461a in StgOpenStorage \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/storage.cxx:70\r\n    #11 0x7fc9f8a7008e in OLEFile::OpenOLEFile(_XGUID&amp;, OLEStorage**, unsigned int) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/ole\/olefiles.cpp:184\r\n    #12 0x7fc9f8a70557 in OLEFile::GetCLSID(_XGUID*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/ole\/olefiles.cpp:346\r\n    #13 0x7fc9f8a52d64 in PFlashPixImageView::PFlashPixImageView(FicNom&amp;, char const*, mode_Ouverture, long, PSearchHookObject*, FPXStatus*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpximgvw.cpp:389\r\n    #14 0x7fc9f8a55c81 in OpenImageByFilename(FicNom&amp;, char const*, unsigned long, unsigned int*, unsigned int*, unsigned int*, unsigned int*, FPXColorspace*, PFlashPixImageView**) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpxlibio.cpp:1629\r\n    #15 0x7fc9f8a55dc9 in FPX_OpenImageByFilename \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpxlibio.cpp:1686\r\n    #16 0x7fc9f8cc45e6 in ReadFPXImage \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/coders\/fpx.c:226:16\r\n    #17 0x7fc9fe564e2b in ReadImage \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/constitute.c:1607:13\r\n    #18 0x7fc9fe561e8c in PingImage \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/constitute.c:1370:9\r\n    #19 0x7fc9fe42dae5 in IdentifyImageCommand \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/command.c:8379:17\r\n    #20 0x7fc9fe434065 in MagickCommand \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/command.c:8869:17\r\n    #21 0x7fc9fe4df7fb in GMCommandSingle \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/command.c:17396:10\r\n    #22 0x7fc9fe4dc931 in GMCommand \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/command.c:17449:16\r\n    #23 0x7fc9fcd47680 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    #24 0x419cd8 in _init (\/usr\/bin\/gm+0x419cd8)\r\n\r\nAddressSanitizer can not provide additional info.\r\nSUMMARY: AddressSanitizer: FPE \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/h\/dirfunc.hxx:250 in CDirVector::GetTable(unsigned int, unsigned int, CDirSect**)\r\n==11203==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n1.3.1_p6<\/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-12924<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00313-libfpx-FPE-CDirVector_GetTable\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00313-libfpx-FPE-CDirVector_GetTable<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-08-01: bug discovered<br \/>\n2017-08-09: blog post about the issue<br \/>\n2017-08-17: 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=\"wGG74bOv0f\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/08\/09\/libfpx-divide-by-zero-in-cdirvectorgettable-dirfunc-hxx\/\">libfpx: divide-by-zero in CDirVector::GetTable (dirfunc.hxx)<\/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\/08\/09\/libfpx-divide-by-zero-in-cdirvectorgettable-dirfunc-hxx\/embed\/#?secret=wGG74bOv0f\" data-secret=\"wGG74bOv0f\" width=\"600\" height=\"338\" title=\"&#8220;libfpx: divide-by-zero in CDirVector::GetTable (dirfunc.hxx)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: libfpx is a library for manipulating FlashPIX images. I&#8217;m aware that the link to the upstream website does not work. I&#8217;m keeping it as well because in the future the upstream website could appear again. Libfpx is not actively &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/08\/09\/libfpx-divide-by-zero-in-cdirvectorgettable-dirfunc-hxx\/\">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-vD","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1961"}],"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=1961"}],"version-history":[{"count":6,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1961\/revisions"}],"predecessor-version":[{"id":2029,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1961\/revisions\/2029"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}