{"id":1082,"date":"2017-01-01T17:36:43","date_gmt":"2017-01-01T15:36:43","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1082"},"modified":"2017-01-01T17:36:43","modified_gmt":"2017-01-01T15:36:43","slug":"libtiff-null-pointer-dereference-in-tiffreadrawdata-tiffinfo-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/01\/01\/libtiff-null-pointer-dereference-in-tiffreadrawdata-tiffinfo-c\/","title":{"rendered":"libtiff: NULL pointer dereference in TIFFReadRawData (tiffinfo.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"http:\/\/libtiff.maptools.org\">Libtiff<\/a> is a software that provides support for the Tag Image File Format (TIFF), a widely used format for storing image data.<\/p>\n<p>A crafted tiff file revealed a NULL pointer access.<\/p>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># tiffinfo -Dijr $FILE\r\n\r\nTIFFReadDirectoryCheckOrder: Warning, Invalid TIFF directory; tags are not sorted in ascending order.\r\nTIFFReadDirectory: Warning, Unknown field with tag 384 (0x180) encountered.\r\nTIFFReadDirectory: Warning, Unknown field with tag 1093 (0x445) encountered.\r\nTIFFReadDirectory: Warning, Unknown field with tag 2 (0x2) encountered.\r\nTIFFFetchNormalTag: Warning, ASCII value for tag \"DocumentName\" contains null byte in value; value incorrectly truncated during reading due to implementation limitations.\r\nTIFFFetchNormalTag: Warning, Incorrect count for \"JpegProc\"; tag ignored.\r\nTIFFReadDirectory: Warning, Photometric tag value assumed incorrect, assuming data is YCbCr instead of RGB.\r\nTIFFReadDirectory: Warning, SamplesPerPixel tag is missing, applying correct SamplesPerPixel value of 3.\r\n_TIFFVSetField: Warning, SamplesPerPixel tag value is changing, but SMinSampleValue tag was read with a different value. Cancelling it.\r\nASAN:DEADLYSIGNAL\r\n=================================================================\r\n==15897==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000050d8ad bp 0x7ffc4a3eaf90 sp 0x7ffc4a3eaec0 T0)\r\n==15897==The signal is caused by a READ memory access.\r\n==15897==Hint: address points to the zero page.\r\n    #0 0x50d8ac in TIFFReadRawData \/tmp\/portage\/media-libs\/tiff-4.0.7\/work\/tiff-4.0.7\/tools\/tiffinfo.c:421:29\r\n    #1 0x50b2de in tiffinfo \/tmp\/portage\/media-libs\/tiff-4.0.7\/work\/tiff-4.0.7\/tools\/tiffinfo.c:473:4\r\n    #2 0x50a999 in main \/tmp\/portage\/media-libs\/tiff-4.0.7\/work\/tiff-4.0.7\/tools\/tiffinfo.c:152:6\r\n    #3 0x7f6258f0961f in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.22-r4\/work\/glibc-2.22\/csu\/libc-start.c:289\r\n    #4 0x419f38 in _init (\/usr\/bin\/tiffinfo+0x419f38)\r\n\r\nAddressSanitizer can not provide additional info.\r\nSUMMARY: AddressSanitizer: SEGV \/tmp\/portage\/media-libs\/tiff-4.0.7\/work\/tiff-4.0.7\/tools\/tiffinfo.c:421:29 in TIFFReadRawData\r\n==15897==ABORTING\r\nTIFF Directory at offset 0xc (12)\r\n  Image Width: 128 Image Length: 1\r\n  Bits\/Sample: 32189\r\n  Compression Scheme: Old-style JPEG\r\n  Photometric Interpretation: YCbCr\r\n  YCbCr Subsampling: 2, 2\r\n  Samples\/Pixel: 3\r\n  Rows\/Strip: 2048\r\n  Planar Configuration: single image plane\r\n  DocumentName: \r\n  Tag 384: 16779264\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n4.0.7<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/vadz\/libtiff\/commit\/c2f931bb558b9db41cb3516a6df3aa600fd85744\">https:\/\/github.com\/vadz\/libtiff\/commit\/c2f931bb558b9db41cb3516a6df3aa600fd85744<\/a><\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo of Gentoo.<\/p>\n<p><strong>CVE:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00056-libtiff-nullptr-TIFFReadRawData\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00056-libtiff-nullptr-TIFFReadRawData<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2016-11-22: bug discovered and reported to upstream<br \/>\n2016-12-03: upstream released a patch<br \/>\n2017-01-01: 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=\"bzBMNDI4th\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/01\/01\/libtiff-null-pointer-dereference-in-tiffreadrawdata-tiffinfo-c\/\">libtiff: NULL pointer dereference in TIFFReadRawData (tiffinfo.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\/2017\/01\/01\/libtiff-null-pointer-dereference-in-tiffreadrawdata-tiffinfo-c\/embed\/#?secret=bzBMNDI4th\" data-secret=\"bzBMNDI4th\" width=\"600\" height=\"338\" title=\"&#8220;libtiff: NULL pointer dereference in TIFFReadRawData (tiffinfo.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: Libtiff is a software that provides support for the Tag Image File Format (TIFF), a widely used format for storing image data. A crafted tiff file revealed a NULL pointer access. The complete ASan output: # tiffinfo -Dijr $FILE &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/01\/01\/libtiff-null-pointer-dereference-in-tiffreadrawdata-tiffinfo-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-hs","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1082"}],"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=1082"}],"version-history":[{"count":2,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1082\/revisions"}],"predecessor-version":[{"id":1085,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1082\/revisions\/1085"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}