{"id":1966,"date":"2017-08-09T19:35:03","date_gmt":"2017-08-09T17:35:03","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1966"},"modified":"2017-08-17T22:02:16","modified_gmt":"2017-08-17T20:02:16","slug":"libfpx-null-pointer-dereference-in-cdirectorygetdirentry-dir-cxx","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/08\/09\/libfpx-null-pointer-dereference-in-cdirectorygetdirentry-dir-cxx\/","title":{"rendered":"libfpx: NULL pointer dereference in CDirectory::GetDirEntry (dir.cxx)"},"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\nASAN:DEADLYSIGNAL\r\n=================================================================\r\n==11276==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000258 (pc 0x7f508f88a3f5 bp 0x000000000007 sp 0x7fffbde029f0 T0)\r\n==11276==The signal is caused by a READ memory access.\r\n==11276==Hint: address points to the zero page.\r\n    #0 0x7f508f88a3f4 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:1097\r\n    #1 0x7f508f88a64e in CDirectory::SetSize(unsigned int, unsigned int) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/dir.cxx:437\r\n    #2 0x7f508f89440a in CDirectStream::WriteAt(unsigned int, void const*, unsigned int, unsigned int*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/sstream.cxx:367\r\n    #3 0x7f508f88e7cd in CExposedStream::Write(void const*, unsigned int, unsigned int*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/expst.cxx:206\r\n    #4 0x7f508f875a3e in OLEStream::Write(void const*, unsigned long) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/ole\/olestrm.cpp:143\r\n    #5 0x7f508f875119 in OLEStream::WriteVT_I4(unsigned int*) \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/ole\/olestrm.cpp:1370\r\n    #6 0x7f508f872ded in OLEPropertySection::Write() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/ole\/oleprops.cpp:476\r\n    #7 0x7f508f873101 in OLEPropertySet::Commit() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/ole\/oleprops.cpp:131\r\n    #8 0x7f508f84da36 in PFlashPixFile::Commit() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpxformt.cpp:581\r\n    #9 0x7f508f84da8f in PFlashPixFile::~PFlashPixFile() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpxformt.cpp:276\r\n    #10 0x7f508f84db78 in PFlashPixFile::~PFlashPixFile() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpxformt.cpp:306\r\n    #11 0x7f508f879ed3 in PHierarchicalImage::~PHierarchicalImage() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/ri_image\/ph_image.cpp:168\r\n    #12 0x7f508f849c38 in PFileFlashPixIO::~PFileFlashPixIO() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/f_fpxio.cpp:277\r\n    #13 0x7f508f8536a5 in PFlashPixImageView::~PFlashPixImageView() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpximgvw.cpp:519\r\n    #14 0x7f508f8536b8 in PFlashPixImageView::~PFlashPixImageView() \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpximgvw.cpp:532\r\n    #15 0x7f508f85529e in FPX_CloseImage \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/fpx\/fpxlibio.cpp:766\r\n    #16 0x7f508fac7bf4 in ReadFPXImage \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/coders\/fpx.c:344:14\r\n    #17 0x7f5095333e2b in ReadImage \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/constitute.c:1607:13\r\n    #18 0x7f5095330e8c in PingImage \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/constitute.c:1370:9\r\n    #19 0x7f50951fcae5 in IdentifyImageCommand \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/command.c:8379:17\r\n    #20 0x7f5095203065 in MagickCommand \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/command.c:8869:17\r\n    #21 0x7f50952ae7fb in GMCommandSingle \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/command.c:17396:10\r\n    #22 0x7f50952ab931 in GMCommand \/var\/tmp\/portage\/media-gfx\/graphicsmagick-1.3.26\/work\/GraphicsMagick-1.3.26\/magick\/command.c:17449:16\r\n    #23 0x7f5093b16680 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: SEGV \/var\/tmp\/portage\/media-libs\/libfpx-1.3.1_p6\/work\/libfpx-1.3.1-6\/oless\/dir.cxx:1097 in CDirectory::GetDirEntry(unsigned int, unsigned int, CDirEntry**)\r\n==11276==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-12920<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00308-libfpx-NULLptr-CDirectory_GetDirEntry\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00308-libfpx-NULLptr-CDirectory_GetDirEntry<\/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=\"itsqNevlQI\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/08\/09\/libfpx-null-pointer-dereference-in-cdirectorygetdirentry-dir-cxx\/\">libfpx: NULL pointer dereference in CDirectory::GetDirEntry (dir.cxx)<\/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-null-pointer-dereference-in-cdirectorygetdirentry-dir-cxx\/embed\/#?secret=itsqNevlQI\" data-secret=\"itsqNevlQI\" width=\"600\" height=\"338\" title=\"&#8220;libfpx: NULL pointer dereference in CDirectory::GetDirEntry (dir.cxx)&#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-null-pointer-dereference-in-cdirectorygetdirentry-dir-cxx\/\">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-vI","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1966"}],"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=1966"}],"version-history":[{"count":7,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1966\/revisions"}],"predecessor-version":[{"id":2036,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1966\/revisions\/2036"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}