Bug 1359718 (CVE-2016-6291)

Summary: CVE-2016-6291 php: Out-of-bounds access in exif_process_IFD_in_MAKERNOTE
Product: [Other] Security Response Reporter: Adam Mariš <amaris>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: abhgupta, dmcphers, fedora, hhorak, jialiu, jokerman, jorton, kseifried, lmeyer, mmccomas, rcollet, tiwillia, webstack-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: php 5.5.38, php 5.6.24, php 7.0.9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-26 19:59:56 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: 1359837, 1789043    
Bug Blocks: 1359830    

Description Adam Mariš 2016-07-25 10:49:05 UTC
An out-of-bounds access due to lack of size check of buffer may lead to memory buffer overflow.

Upstream bug:

https://bugs.php.net/bug.php?id=72603

Upstream patch:

http://git.php.net/?p=php-src.git;a=commit;h=eebcbd5de38a0f1c2876035402cb770e37476519

CVE assignment:

http://seclists.org/oss-sec/2016/q3/137

Comment 1 Adam Mariš 2016-07-25 14:12:34 UTC
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1359837]

Comment 2 Huzaifa S. Sidhpurwala 2016-08-05 06:06:41 UTC
Analysis:

In the affected code snippet:

offset_diff = 2 + NumDirEntries*12 + 4 - php_ifd_get32u(dir_start+10, ImageInfo->motorola_intel);

The output from the php_ifd_get32u() function and the NumDirEntries are attacker controlled, via a specially-crafted JPG image. This results in offset_diff being controlled by the user. Later in the code offset_diff is used to read the IFD tag, which could ultimately lead to OOB Read.

For successful exploitation, a specially crafted JPG image, needs to be read by the PHP script, via exif_read_data() function.

Comment 3 Remi Collet 2016-08-05 06:12:13 UTC
For memory, the recent exif CVE introduce a regression in MakerNote parser.

Regression fixed in:

http://git.php.net/?p=php-src.git;a=commitdiff;h=d5796fb298abb2a3e389818ad924589fa35e58b9

http://git.php.net/?p=php-src.git;a=commitdiff;h=9667ee4f72c7dafce993b71104a52beb7c3aff15

Comment 4 errata-xmlrpc 2016-11-15 11:43:29 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 6
  Red Hat Software Collections for Red Hat Enterprise Linux 6.7 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7
  Red Hat Software Collections for Red Hat Enterprise Linux 7.2 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7.3 EUS

Via RHSA-2016:2750 https://rhn.redhat.com/errata/RHSA-2016-2750.html