Bug 1069213 (CVE-2017-16232)

Summary: VUL-1: CVE-2017-16232: tiff: memory-based DoS in tiff2bw
Product: [Novell Products] SUSE Security Incidents Reporter: Victor Pereira <vpereira>
Component: IncidentsAssignee: Michael Vetter <mvetter>
Status: RESOLVED UPSTREAM QA Contact: Security Team bot <security-team>
Severity: Minor    
Priority: P4 - Low CC: meissner, mvetter, pgajdos, smash_bz
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://smash.suse.de/issue/194356/
Whiteboard: CVSSv3:SUSE:CVE-2017-16232:2.8:(AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:N/A:L) CVSSv3:RedHat:CVE-2017-16232:3.3:(AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L)
Found By: Security Response Team Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: libtiff_poc_tif.bin

Description Victor Pereira 2017-11-21 14:16:37 UTC
CVE-2017-16232

LibTIFF 4.0.8 has multiple memory leak vulnerabilities, which allow
attackers to cause a denial of service (memory consumption), as demonstrated
by tif_open.c, tif_lzw.c, and tif_aux.c


References:
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-16232
http://seclists.org/oss-sec/2017/q4/164
http://people.canonical.com/~ubuntu-security/cve/2017/CVE-2017-16232.html
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-16232
Comment 1 Marcus Meissner 2018-01-12 08:34:20 UTC
Created attachment 755813 [details]
libtiff_poc_tif.bin

QA REPRODUCER:

tiff2bw libtiff_poc_tif.bin foo.tif

will run quickly out of memory
Comment 2 Marcus Meissner 2018-01-12 08:37:31 UTC
this is partially in the tiff2bw tool itself where libtiff maitnainers do not want to fix it.
Comment 3 Swamp Workflow Management 2018-01-12 14:09:12 UTC
SUSE-SU-2018:0073-1: An update that fixes 5 vulnerabilities is now available.

Category: security (important)
Bug References: 1017690,1069213,960341,969783,983436
CVE References: CVE-2014-8128,CVE-2015-7554,CVE-2016-10095,CVE-2016-5318,CVE-2017-16232
Sources used:
SUSE Linux Enterprise Software Development Kit 12-SP3 (src):    tiff-4.0.9-44.7.1
SUSE Linux Enterprise Software Development Kit 12-SP2 (src):    tiff-4.0.9-44.7.1
SUSE Linux Enterprise Server for Raspberry Pi 12-SP2 (src):    tiff-4.0.9-44.7.1
SUSE Linux Enterprise Server 12-SP3 (src):    tiff-4.0.9-44.7.1
SUSE Linux Enterprise Server 12-SP2 (src):    tiff-4.0.9-44.7.1
SUSE Linux Enterprise Desktop 12-SP3 (src):    tiff-4.0.9-44.7.1
SUSE Linux Enterprise Desktop 12-SP2 (src):    tiff-4.0.9-44.7.1
Comment 4 Swamp Workflow Management 2018-01-15 14:15:42 UTC
openSUSE-SU-2018:0097-1: An update that fixes 5 vulnerabilities is now available.

Category: security (important)
Bug References: 1017690,1069213,960341,969783,983436
CVE References: CVE-2014-8128,CVE-2015-7554,CVE-2016-10095,CVE-2016-5318,CVE-2017-16232
Sources used:
openSUSE Leap 42.3 (src):    tiff-4.0.9-24.1
openSUSE Leap 42.2 (src):    tiff-4.0.9-17.9.1
Comment 5 Petr Gajdos 2018-11-21 13:43:04 UTC
4.0.10, 4.0.9:

$ valgrind -q --leak-check=full tiff2bw libtiff_poc_tif.bin foo.tif
LZWDecode: Not enough data at scanline 0 (short 6442443006 bytes).
$

Neither ASAN reports an error.

4.0.8:

$ valgrind -q --leak-check=full tiff2bw libtiff_poc_tif.bin out.tiff
LZWDecode: Not enough data at scanline 0 (short 6442443006 bytes).
==22463== 87,062 (1,100 direct, 85,962 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 15
==22463==    at 0x4C2E08F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22463==    by 0x4E9D7AB: _TIFFmalloc (tif_unix.c:316)
==22463==    by 0x4E89A90: TIFFClientOpen (tif_open.c:119)
==22463==    by 0x4E9D655: TIFFFdOpen (tif_unix.c:211)
==22463==    by 0x4E9D76A: TIFFOpen (tif_unix.c:250)
==22463==    by 0x109642: main (tiff2bw.c:159)
==22463== 
==22463== 2,147,483,702 bytes in 1 blocks are possibly lost in loss record 14 of 15
==22463==    at 0x4C2E08F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22463==    by 0x4E9D7AB: _TIFFmalloc (tif_unix.c:316)
==22463==    by 0x109B5A: main (tiff2bw.c:225)
==22463== 
==22463== 6,442,451,106 bytes in 1 blocks are possibly lost in loss record 15 of 15
==22463==    at 0x4C2E08F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==22463==    by 0x4E9D7AB: _TIFFmalloc (tif_unix.c:316)
==22463==    by 0x109EA6: main (tiff2bw.c:258)
==22463== 
$

The leaks are caused by not calling TIFFClose() on `inĀ“ and TIFFfree() on inbuf and outbuf in error path.

3.8.2

$ valgrind -q --leak-check=full tiff2bw libtiff_poc_tif.bin out.tif
libtiff_poc_tif.bin: Integer overflow in TIFFScanlineSize.
TIFFReadDirectory: libtiff_poc_tif.bin: cannot handle zero scanline size.
$

However, there are many possible memory leaks in 3.8.2/tools/tiff2bw.c's main(). While this is not an issue the more it is not a security one, closing as UPSTREAM.