Bug 529213 (CVE-2009-3546)

Summary: CVE-2009-3546 gd: insufficient input validation in _gdGetColors()
Product: [Other] Security Response Reporter: Tomas Hoger <thoger>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: extras-orphan, fedora, jlieskov, jmoskovc, jorton, kreilly, pertusus, rpm, varekova, vdanen
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-03-29 09:10:25 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: 537908, 541594, 541595, 541596, 541597, 541598, 541630, 541631, 541632, 541633, 548502, 647242, 830745, 833901    
Bug Blocks:    

Description Tomas Hoger 2009-10-15 14:34:08 UTC
While investigating CVE-2009-3293 (bug #524217) fixed in PHP 5.2.11, it was discovered that _gdGetColors() (in libgd/gd_gd.c) does not properly check values read from the input GD file, making it possible to set im->colorsTotal to a value greater than gdMaxColors.  GD code assumes that colorsTotal is always less than or equal to gdMaxColors, as it is used as an upper bound when accessing arrays with gdMaxColors size.  Higher colorsTotal value can lead to buffer over-reads or over-writes on multiple places.

Issue was reported and fixed upstream:
  http://svn.php.net/viewvc?view=revision&revision=289557

Fix should get include in the future PHP and GD versions.

Note: GD image format is not meant for general purpose use and should not be used to distribute images.  Its purpose is to allow fast loading by applications using libGD:
  http://www.libgd.org/GdFileFormats

This affects gd in Red Hat Enterprise Linux 4 and 5, version in Red Hat Enterprise Linux 3 is not affected.

It also affects all current PHP versions (Red Hat Enterprise Linux 3, 4 and 5, Fedora), as they include embedded copy of gd 2.x.

Comment 2 Jan Lieskovsky 2009-10-20 08:47:44 UTC
MITRE's CVE-2009-3546 record:
------------------------------

The _gdGetColors function in gd_gd.c in PHP 5.2.11 and 5.3.0, and the
GD Graphics Library 2.x, does not properly verify a certain
colorsTotal structure member, which might allow remote attackers to
conduct buffer overflow or buffer over-read attacks via a crafted GD
file, a different vulnerability than CVE-2009-3293. NOTE: some of
these details are obtained from third party information.

Comment 4 Fedora Update System 2009-11-20 20:53:42 UTC
php-5.3.1-1.fc12,maniadrive-1.2-19.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/php-5.3.1-1.fc12,maniadrive-1.2-19.fc12

Comment 8 Fedora Update System 2009-12-04 23:35:46 UTC
php-5.3.1-1.fc12, maniadrive-1.2-19.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 errata-xmlrpc 2010-01-04 18:26:32 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 4
  Red Hat Enterprise Linux 5

Via RHSA-2010:0003 https://rhn.redhat.com/errata/RHSA-2010-0003.html

Comment 11 errata-xmlrpc 2010-01-13 18:10:08 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5
  Red Hat Enterprise Linux 4
  Red Hat Enterprise Linux 3

Via RHSA-2010:0040 https://rhn.redhat.com/errata/RHSA-2010-0040.html

Comment 12 Fedora Update System 2010-02-01 01:09:10 UTC
php-5.2.12-1.fc11, maniadrive-1.2-17.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 13 Vincent Danen 2010-10-27 16:46:19 UTC
As noted in a Debian bug report [1], plt-scheme has an embedded copy of GD that is vulnerable to this.  I'm not sure if it's possible to make plt-scheme link to the system libgd or not (I would hope it is), but regardless this needs to be fixed.

I verified that the _gdGetColors() function exists in both F12 and F13 by searching on binary symbols:

$ ./rqp -z gdGetColors
rqp 0.6 ($Id: rqp 395 2010-10-17 04:26:14Z vdanen $)

Searching database records for substring match for symbols (gdGetColors)


Results in Tag: f12_i386
========================================

gd-2.0.35-9.fc12 (gd): _gdGetColors in /usr/lib/libgd.so.2.0.0
plt-scheme-4.1.2-3.fc12 (plt-scheme): _gdGetColors in /usr/lib/plt/collects/plot/compiled/native/i386-linux/libplplot.so


Results in Tag: f12_x86_64
========================================

gd-2.0.35-9.fc12 (gd): _gdGetColors in /usr/lib/libgd.so.2.0.0
gd-2.0.35-9.fc12 (gd): _gdGetColors in /usr/lib64/libgd.so.2.0.0
plt-scheme-4.1.2-3.fc12 (plt-scheme): _gdGetColors in /usr/lib64/plt/collects/plot/compiled/native/x86_64-linux/libplplot.so


Similar results in F13 and I suspect F14 and rawhide as well.

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=601525

Comment 15 Tomas Hoger 2012-06-11 10:28:38 UTC
Created gd tracking bugs for this issue

Affects: fedora-all [bug 830745]