Bugzilla – Bug 129642
VUL-0: CVE-2005-3186: gdk-pixbuf: XPM buffer overflow
Last modified: 2021-11-03 15:06:15 UTC
Hi, we reveive this message via vendor-sec. CRD: 3rd Nov. 2005 CAN-2005-3186. 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. -- JB Content-Description: xpm-advisory.txt Multiple Vendor GTK+ gdk-pixbuf XPM Loader Heap Overflow Vulnerability iDEFENSE Security Advisory XX.XX.05 http://www.idefense.com/application/poi/display?type=vulnerabilities MMM DD, 2005 I. BACKGROUND 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. II. DESCRIPTION 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 provided. The vulnerability specifically exists due to an integer overflow while processing XPM files. The following code snippet illustrates the vulnerability: if (n_col <= 0 || n_col >= G_MAXINT / (cpp + 1)) { g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, _("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. III. ANALYSIS 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. IV. DETECTION 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 V. WORKAROUND Do not open untrusted media files. VI. VENDOR RESPONSE [Quoted vendor response if available. Otherwise include vendor fix details.] VII. CVE INFORMATION 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. [OR] A Mitre Corp. Common Vulnerabilities and Exposures (CVE) number has not been assigned yet. VIII. DISCLOSURE TIMELINE 10/12/2005 Initial vendor notification XX/XX/2005 Initial vendor response XX/XX/2005 Coordinated public disclosure IX. CREDIT infamous41md is credited with the discovery of this vulnerability. Get paid for vulnerability research http://www.idefense.com/poi/teams/vcp.jsp Free tools, research and upcoming events http://labs.idefense.com X. LEGAL NOTICES 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, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, ----- End forwarded message -----
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?
In older versions of gtk2 also some checks are missings (e. g. Invalid XPM header in 9.2 and older).
Sounds right to me.
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.
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.
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.
Maintenance-Tracker-2655
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).
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
Please also submit a gtk2 version for SLES9-SLD.
Done.
Thanks!
not really a security problem but pixbuf runs into an endless loop when trying to load ~lnussel/Export/pixbuf/q3-loop.xpm
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
I will be on vacation until Monday.
Created attachment 55708 [details] fix for w*h*c overflow
Created attachment 55709 [details] fix for endless loop. also needed in gtk2.
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.
Who is responsible for this as long as Stansilav is on vacation? Please integrate the new patches and resubmit packages, thanks.
Ok, thanks. Note that the issue is still under embargo so please hold back packages for STABLE for now.
Packages are resubmitted.
What's with gtk2? Comment #17 seems to indicate that it has to be resubmitted as well.
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.
CRD moved to Nov 15.
gtk2 packages are submitted too.
thanks!
gtk2 update packages with Oct 31 fix are missing for SLEC and NLD (sles8-slec-i386,sles9-sld-i386,sles9-sld-x86_64)
packages for SLEC and NLD submitted, sorry.
packages tested, release tomorrow
packages approved
Updated packages submitted for STABLE and PLUS.
CVE-2005-3186: CVSS v2 Base Score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)