Bug 1351068 (CVE-2016-5766)

Summary: CVE-2016-5766 gd: Integer overflow in _gd2GetHeader() resulting in heap overflow
Product: [Other] Security Response Reporter: Andrej Nemec <anemec>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: abhgupta, databases-maint, dmcphers, fedora, fjanus, hhorak, jialiu, jokerman, jorton, lmeyer, mmccomas, panovotn, rcollet, tiwillia, webstack-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: php 5.5.37, php 5.6.23, gd 2.2.3 Doc Type: If docs needed, set a value
Doc Text:
An integer overflow flaw, leading to a heap-based buffer overflow was found in the imagecreatefromgd2() function of PHP's gd extension. A remote attacker could use this flaw to crash a PHP application or execute arbitrary code with the privileges of the user running that PHP application using gd via a specially crafted GD2 image.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-08 02:56:00 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: 1351180, 1356812, 1356813    
Bug Blocks: 1323912, 1351183    

Description Andrej Nemec 2016-06-29 07:18:12 UTC
The _gd2GetHeader() is prone to an integer overflow, which result in heap based overflow.

Upstream bug:

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

Upstream patch:

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

CVE assignment:

http://seclists.org/oss-sec/2016/q2/589

Comment 1 Andrej Nemec 2016-06-29 12:04:41 UTC
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1351180]

Comment 2 Fedora Update System 2016-07-02 15:27:45 UTC
php-5.6.23-1.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 3 Fedora Update System 2016-07-02 19:22:33 UTC
php-5.6.23-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Comment 4 Fedora Update System 2016-07-02 19:27:51 UTC
php-5.6.23-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 5 Huzaifa S. Sidhpurwala 2016-07-11 10:01:22 UTC
Analysis:

When imagecreatefromgd2() is fed a GD2 image format, which has a malformed (or a specially-crafted) headers, it causes integer overflow, followed by heap-buffer overflow.

In a typical PHP situation, the attacker needs to trigger this by uploading a specially-crafted gd image to a php application, something which is unlikely.

Comment 8 errata-xmlrpc 2016-11-03 21:05:07 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

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

Comment 10 errata-xmlrpc 2016-11-15 11:41:17 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

Comment 12 errata-xmlrpc 2020-12-15 11:17:24 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2020:5443 https://access.redhat.com/errata/RHSA-2020:5443