Bug 1389229 (CVE-2016-8331)

Summary: CVE-2016-8331 libtiff: FAX IFD Entry Parsing Type Confusion
Product: [Other] Security Response Reporter: Andrej Nemec <anemec>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: erik-fedora, kabbott, nforro, phracek, sardella, slawomir
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-17 08:46:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1389231, 1389232, 1389233    
Bug Blocks: 1389235    

Description Andrej Nemec 2016-10-27 08:44:58 UTC
An exploitable remote code execution vulnerability exists in the handling of TIFF images in LibTIFF. A crafted TIFF document can lead to a type confusion vulnerability resulting in remote code execution. This vulnerability can be triggered via a TIFF file delivered to the application using LibTIFF’s tag extension functionality.

External References:

http://www.talosintelligence.com/reports/TALOS-2016-0190

Comment 1 Andrej Nemec 2016-10-27 08:47:33 UTC
Created libtiff tracking bugs for this issue:

Affects: fedora-all [bug 1389231]

Comment 2 Andrej Nemec 2016-10-27 08:47:39 UTC
Created mingw-libtiff tracking bugs for this issue:

Affects: fedora-all [bug 1389232]
Affects: epel-7 [bug 1389233]

Comment 3 Huzaifa S. Sidhpurwala 2016-11-07 06:06:52 UTC
Analysis:

The flaw is possibly caused by expecting a double value on the argument list, va_arg and there is none. This results in a possible sizeof(double) OOB read/write. This may result in a crash, or a difficult to pull off code exec.

Comment 8 Nikola Forró 2017-01-17 08:34:30 UTC
Analysis:

The reproducer reads BadFaxLines tag like this:

uint32 *a;
TiffGetField(tiff, TIFFTAG_BADFAXLINES, &a);

Despite the documentation, which says:

Tag Name            Count   Types
TIFFTAG_BADFAXLINES 1       uint32*

the correct way how to read the tag is this:

uint32 count;
uint16 *values;
TIFFGetField(tiff, TIFFTAG_BADFAXLINES, &count, &values);

That is because TIFFTAG_BADFAXLINES is considered an anonymous custom tag, and as such is has to be read as count and array of values.

The reproducer does exactly what thumbnail utility is doing when it is processing BadFaxLines tag. However, processing this tag has been disabled in RHEL with patch for CVE-2016-3632. That means RHEL packages are not affected.