Bug 984816 (CVE-2016-5322) - VUL-1: tiff: CVE-2016-5322: Out-of-bounds read in extractContigSamplesBytes() function
Summary: VUL-1: tiff: CVE-2016-5322: Out-of-bounds read in extractContigSamplesBytes()...
Status: RESOLVED FIXED
Alias: CVE-2016-5322
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents (show other bugs)
Version: unspecified
Hardware: Other Other
: P4 - Low : Normal
Target Milestone: ---
Assignee: Michael Vetter
QA Contact: Security Team bot
URL: https://smash.suse.de/issue/170092/
Whiteboard: CVSSv2:RedHat:CVE-2016-5322:4.3:(AV:N...
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-15 10:09 UTC by Marcus Meissner
Modified: 2019-04-25 14:43 UTC (History)
3 users (show)

See Also:
Found By: Security Response Team
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Meissner 2016-06-15 10:09:10 UTC
http://seclists.org/oss-sec/2016/q2/550


Details
=======

Product: libtiff
Affected Versions: <= 4.0.6
Vulnerability Type: illegel read
Vendor URL: http://www.remotesensing.org/libtiff/
Credit: Kaixiang Zhang of the Cloud Security Team, Qihoo 360
CVE ID: CVE-2016-5322
Tested system version:
       fedora23 32bit
       fedora23 64bit
       CentOS Linux release 7.1.1503 64bit

Introduction
=======

It was always corrupted when I use tiffcrop command followed by a crafted TIFF image .The vulnerbility exists in 
extractContigSamplesBytes() without checking the buffer length when reading, Attackers could exploit this issue to 
cause denial-of-service.

Here is the stack info:
gdb –args ./tiffcrop extractContigSamplesBytes.tif tmpout.tif
--- ---
Program received signal SIGSEGV, Segmentation fault.
extractContigSamplesBytes (in=0x6647b0 "@z\335\367\377\177", out=out@entry=0x66d9a0 "@z\335\367\377\177", 
cols=cols@entry=32, sample=sample@entry=0, spp=spp@entry=16385, bps=bps@entry=256, count=count@entry=1, start=1, 
start@entry=0,
    end=end@entry=32) at tiffcrop.c:2705
2705                     *dst++ = *src++;
(gdb) bt
#0  extractContigSamplesBytes (in=0x6647b0 "@z\335\367\377\177", out=out@entry=0x66d9a0 "@z\335\367\377\177", 
cols=cols@entry=32, sample=sample@entry=0, spp=spp@entry=16385, bps=bps@entry=256, count=count@entry=1, start=1,
    start@entry=0, end=end@entry=32) at tiffcrop.c:2705
#1  0x00000000004379a7 in extractContigSamplesToBuffer (dump=<optimized out>, bps=256, spp=16385, sample=0, 
cols=<optimized out>, rows=<optimized out>, in=0x6647b0 "@z\335\367\377\177", out=0x66d9a0 "@z\335\367\377\177")
    at tiffcrop.c:3493
#2  writeBufferToSeparateStrips (out=out@entry=0x662570, buf=buf@entry=0x6647b0 "@z\335\367\377\177", 
length=length@entry=32, width=width@entry=32, spp=spp@entry=16385, dump=dump@entry=0x7fffffffc260) at tiffcrop.c:1165
#3  0x000000000043e729 in writeCroppedImage (in=in@entry=0x662010, out=0x662570, image=image@entry=0x7fffffff7950, 
dump=dump@entry=0x7fffffffc260, width=32, length=32, crop_buff=crop_buff@entry=0x6647b0 "@z\335\367\377\177",
    pagenum=pagenum@entry=0, total_pages=total_pages@entry=1) at tiffcrop.c:7866
#4  0x0000000000408acb in main (argc=<optimized out>, argv=<optimized out>) at tiffcrop.c:2326
(gdb) p src
$4 = (uint8 *) 0x6e47d0 <Address 0x6e47d0 out of bounds>
Comment 1 Swamp Workflow Management 2016-06-15 22:01:54 UTC
bugbot adjusting priority
Comment 3 Petr Gajdos 2018-06-04 10:31:58 UTC
Upstream bug:
http://bugzilla.maptools.org/show_bug.cgi?id=2560
Upstream fix:
Upstream bug #2560 was closed as duplicate of #2543, which was fixed by
https://gitlab.com/libtiff/libtiff/commit/5dd73c2b77798cebe22f8668187e502ad462c588

The fix is related to tiffcrop utility, which does not exist in 10sp3,11/tiff. 12/tiff has the fix already in.