Bug 129642 - (CVE-2005-3186) VUL-0: CVE-2005-3186: gdk-pixbuf: XPM buffer overflow
VUL-0: CVE-2005-3186: gdk-pixbuf: XPM buffer overflow
Classification: Novell Products
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents
Other Other
: P5 - None : Major
: ---
Assigned To: Security Team bot
Security Team bot
CVE-2005-3186: CVSS v2 Base Score: 7....
Depends on:
  Show dependency treegraph
Reported: 2005-10-20 07:28 UTC by Thomas Biege
Modified: 2021-11-03 15:06 UTC (History)
5 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---

fix for w*h*c overflow (1.60 KB, patch)
2005-10-27 13:38 UTC, Ludwig Nussel
Details | Diff
fix for endless loop. also needed in gtk2. (504 bytes, patch)
2005-10-27 13:39 UTC, Ludwig Nussel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Biege 2005-10-20 07:28:10 UTC
we reveive this message via vendor-sec.

CRD: 3rd Nov. 2005

To: vendor-sec@lst.de
Cc: mclasen@redhat.com, vendor-disclosure@idefense.com
From: Josh Bressers <bressers@redhat.com>
Subject: [vendor-sec] iDEFENSE gdk-pixbuf/gtk+ XPM buffer overflow
Errors-To: vendor-sec-admin@lst.de
Date: Wed, 19 Oct 2005 13:06:36 -0500

iDEFENSE recently contacted the gdk-pixbuf/gtk+ maintainers with the
following advisory.  The demo exploit and patch were written by one of our
developers, Matthias Clasen.  He asked me to forward this on to vendor-sec.

The current embargoed date is Nov 3.  This issue has been assigned the CVE
id CAN-2005-3186.


Content-Description: xpm-advisory.txt
Multiple Vendor GTK+ gdk-pixbuf XPM Loader Heap Overflow Vulnerability

iDEFENSE Security Advisory XX.XX.05
MMM DD, 2005


GTK+ is a multi-platform toolkit for creating graphical user interfaces.
Offering a complete set of widgets, GTK+ is suitable for projects
ranging from small one-off projects to complete application suites.


Remote exploitation of heap overflow vulnerability in various vendors'
implementations of the GTK+ gdk-pixbuf XPM image rendering library could
allow for arbitrary code execution. iDEFENSE is currently unaware of
exploits for this vulnerability other than those maintainted by iDEFENSE
Labs, however exploitation is trivial. Vendor patches for this iDEFENSE
exclusive report are currently unavailable. A workaround has been

The vulnerability specifically exists due to an integer overflow while
processing XPM files. The following code snippet illustrates the

if (n_col <= 0 || n_col >= G_MAXINT / (cpp + 1)) {
                g_set_error (error,
                             _("XPM file has invalid number of colors"));
        return NULL;
colors = (XPMColor *) g_try_malloc ((sizeof (XPMColor) * n_col));

The validity check of n_col is enough to prevent an integer overflow in
the first g_try_malloc, however there is not a proper check for the
second g_try_malloc, which allows an undersized heap buffer to be
allocated, then overflowed while using n_col as an upper bounds in a
copying loop. This can be used to execute arbitrary code via traditional
heap overflow 4 byte write methods or by overwriting adjacent areas of
the heap with important values such as function pointers.


Exploitation could allow for arbitrary code execution in the context of
the user running the affected application. As this library is used in a
variety of applications, this vulnerability could be exploited either
remotely, via a networked application or locally.


iDEFENSE has confirmed the existence of this vulnerability in gtk+ 2.4.0
compiled from source. It is suspected that previous versions are also
affected by this vulnerability. The following vendors include
susceptible GTK+ and GdkPixBuf packages within their respective
operating system distributions:

        The Debian Project: Debian GNU/Linux 3.0 and 3.1 (all architectures)
        Mandriva (formerly Mandrakesoft): Mandriva Linux (formerly
Mandrakelinux) 10.0 and 10.1, Corporate Server 3.0
        Novell Inc. SuSE Linux 8.2, 9.0, 9.1 and 9.2
        Red Hat Inc.: Linux 9.0 and 7.3, Fedora Core 1, 2,3 and 4, Desktop v.3
and v.4, Enterprise Linux AS/ES/WS v.2.1, v.3 and v.4 and Advanced
+Workstation 2.1 for the Itanium Processor


Do not open untrusted media files.


[Quoted vendor response if available. Otherwise include vendor fix


The Common Vulnerabilities and Exposures (CVE) project has assigned the
name CAN-2005-XXXX to this issue. This is a candidate for inclusion in
the CVE list (http://cve.mitre.org), which standardizes names for
security problems.


A Mitre Corp. Common Vulnerabilities and Exposures (CVE) number has not
been assigned yet.


10/12/2005  Initial vendor notification
XX/XX/2005  Initial vendor response
XX/XX/2005  Coordinated public disclosure


infamous41md is credited with the discovery of this vulnerability.

Get paid for vulnerability research

Free tools, research and upcoming events


Copyright ᅵ 2005 iDEFENSE, Inc.

Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without the express
written consent of iDEFENSE. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically, please
email customerservice@idefense.com for permission.

Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.
Content-Description: xpm-overflow.patch
Index: io-xpm.c
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-xpm.c,v
retrieving revision 1.49
diff -u -p -r1.49 io-xpm.c
--- io-xpm.c    8 Mar 2005 03:59:45 -0000       1.49
+++ io-xpm.c    14 Oct 2005 04:10:30 -0000
@@ -500,7 +500,9 @@ pixbuf_create_from_xpm (const gchar * (*
                              _("XPM has invalid number of chars per pixel"));
                return NULL;
-       if (n_col <= 0 || n_col >= G_MAXINT / (cpp + 1)) {
+       if (n_col <= 0 ||
+           n_col >= G_MAXINT / (cpp + 1) ||
+           n_col >= G_MAXINT / sizeof (XPMColor)) {
                 g_set_error (error,

----- End forwarded message -----
Comment 1 Stanislav Brabec 2005-10-20 15:58:02 UTC
Comparing new code in gtk/gdk-pixbif and old code in gtk-pixbuf from GTK1, many header checks are missing (including this one):

GTK2 has:

No XPM header found
Invalid XPM header
XPM file has image width <= 0
XPM file has image height <= 0
XPM has invalid number of chars per pixel
XPM file has invalid number of colors

GTK1 has:

No XPM header found
XPM has more than 31 chars per pixel.

Should I will backport all these checks?
Comment 2 Stanislav Brabec 2005-10-20 16:04:01 UTC
In older versions of gtk2 also some checks are missings (e. g. Invalid XPM header in 9.2 and older).
Comment 3 JP Rosevear 2005-10-20 16:14:55 UTC
Sounds right to me.
Comment 4 Stanislav Brabec 2005-10-20 17:11:29 UTC
Submitted fixes for GTK2:
gtk2-sles8-all gtk2-sles8-slec-all gtk2-stable-all gtk2-10.0-all gtk2-9.0-all gtk2-9.1-all gtk2-9.2-all gtk2-9.3-all

Will continue with GTK1 gdk-pixbuf backporting.
Comment 5 Federico Mena Quintero 2005-10-20 20:10:46 UTC
Thanks for doing the backport, Stanislav :)

Are the loaders very different in gdk-pixbuf-1?  I really don't remember at this point.

Matthias Clasen has told me that he'll do a GTK+ release around the deadline for the advisory (Nov 3); it will have the patch in there.
Comment 6 Stanislav Brabec 2005-10-21 09:24:47 UTC
To Federico: No. loaders are similar. And oldest gtk2 don't support x_hot, y_hot - I have removed them from sscanf and the check. I will let you know after submit to verify patches.
Comment 7 Ludwig Nussel 2005-10-21 12:29:52 UTC
Comment 8 Stanislav Brabec 2005-10-21 14:39:30 UTC
It looks, that gdk-pixbuf in 9.2, 9.3 and 10.0 has not fix for security bug 59100 (I don't have access to this bug).
Comment 9 Stanislav Brabec 2005-10-21 15:19:53 UTC
Patches submitted for sles8, 9.0, 9.1, 9.2, 9.3, 10.0. For 9.2, 9.3, 10.0 altogether with fix of bug 59100.

Federico: You can verify my backports in /work/src/done/*/gdk-pixbuf
Comment 10 Michael Schröder 2005-10-24 14:26:20 UTC
Please also submit a gtk2 version for SLES9-SLD.
Comment 11 Stanislav Brabec 2005-10-24 14:48:50 UTC
Comment 12 Michael Schröder 2005-10-24 14:50:51 UTC
Comment 13 Ludwig Nussel 2005-10-26 13:04:22 UTC
not really a security problem but pixbuf runs into an endless loop when trying to load ~lnussel/Export/pixbuf/q3-loop.xpm
Comment 14 Ludwig Nussel 2005-10-26 13:24:22 UTC
man, io-xpm in gdk-pixbuf lacks the most basic check of all. It doesn't check whether width*height*depth overflows. There is just a pixels = malloc (w * h * 4);

gtk2 has the checks in gdk_pixbuf_new which is used instead of directly calling malloc
Comment 15 Stanislav Brabec 2005-10-26 15:31:29 UTC
I will be on vacation until Monday.
Comment 16 Ludwig Nussel 2005-10-27 13:38:48 UTC
Created attachment 55708 [details]
fix for w*h*c overflow
Comment 17 Ludwig Nussel 2005-10-27 13:39:26 UTC
Created attachment 55709 [details]
fix for endless loop. also needed in gtk2.
Comment 18 Ludwig Nussel 2005-10-28 07:05:37 UTC
CVE-2005-2975 gdk-pixbuf xpm too many colors DoS
CVE-2005-2976 gdk-pixbuf xpm integer overflow w*h*c

CRD remains Nov 3rd. Please provide new packages.
Comment 19 Ludwig Nussel 2005-10-28 13:40:06 UTC
Who is responsible for this as long as Stansilav is on vacation? Please integrate the new patches and resubmit packages, thanks.
Comment 21 Ludwig Nussel 2005-10-31 13:12:22 UTC
Ok, thanks. Note that the issue is still under embargo so please hold back packages for STABLE for now.
Comment 22 Vladimir Nadvornik 2005-10-31 13:35:25 UTC
Packages are resubmitted.
Comment 23 Michael Schröder 2005-10-31 15:12:01 UTC
What's with gtk2? Comment #17 seems to indicate that it has to be resubmitted as well.
Comment 24 Ludwig Nussel 2005-10-31 15:16:08 UTC
yes. gtk2 is only a endless loop left but since others are going to patch it and gtk2 was not in qa yet I'd prefer if we patch it as well.
Comment 25 Ludwig Nussel 2005-10-31 16:07:14 UTC
CRD moved to Nov 15.
Comment 26 Vladimir Nadvornik 2005-10-31 16:12:47 UTC
gtk2 packages are submitted too.
Comment 27 Ludwig Nussel 2005-10-31 16:16:03 UTC
Comment 28 Ruediger Oertel 2005-11-02 17:26:25 UTC
gtk2 update packages with Oct 31 fix are missing for SLEC and NLD
Comment 29 Vladimir Nadvornik 2005-11-03 09:58:30 UTC
packages for SLEC and NLD submitted, sorry.
Comment 30 Thomas Biege 2005-11-14 11:06:10 UTC
packages tested, release tomorrow
Comment 31 Thomas Biege 2005-11-15 15:09:52 UTC
packages  approved
Comment 32 Stanislav Brabec 2005-11-15 17:07:27 UTC
Updated packages submitted for STABLE and PLUS.
Comment 33 Thomas Biege 2009-10-13 21:43:09 UTC
CVE-2005-3186: CVSS v2 Base Score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)