Bug 529213 (CVE-2009-3546) - CVE-2009-3546 gd: insufficient input validation in _gdGetColors()
Summary: CVE-2009-3546 gd: insufficient input validation in _gdGetColors()
Alias: CVE-2009-3546
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
Depends On: Confidential537908 Engineering541594 Engineering541595 Engineering541596 Engineering541597 Engineering541598 Engineering541630 Engineering541631 Engineering541632 Engineering541633 Engineering548502 Confidential647242 830745 Engineering833901
TreeView+ depends on / blocked
Reported: 2009-10-15 14:34 UTC by Tomas Hoger
Modified: 2019-09-29 12:32 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-03-29 09:10:25 UTC

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2010:0003 0 normal SHIPPED_LIVE Moderate: gd security update 2010-01-04 18:26:21 UTC
Red Hat Product Errata RHSA-2010:0040 0 normal SHIPPED_LIVE Moderate: php security update 2010-01-13 18:09:32 UTC

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:

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:

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.

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]

Note You need to log in before you can comment on or make changes to this bug.