iDEFENSE Security Advisory 11.15.05: Multiple Vendor GTK+ gdk-pixbuf XPM Loader Heap Overflow Vulnerability

2005-11-16T00:00:00
ID SECURITYVULNS:DOC:10246
Type securityvulns
Reporter Securityvulns
Modified 2005-11-16T00:00:00

Description

Multiple Vendor GTK+ gdk-pixbuf XPM Loader Heap Overflow Vulnerability

iDEFENSE Security Advisory 11.15.05 www.idefense.com/application/poi/display?id=339&type=vulnerabilities November 15, 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.

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 &#40;all architectures&#41;
Mandriva &#40;formerly Mandrakesoft&#41;:
  Mandriva Linux &#40;formerly Mandrakelinux&#41; 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.:
  Red Hat Enterprise Linux 2.1, 3, 4,
  Fedora Core 3, 4

V. WORKAROUND

Users should not open untrusted media files.

VI. VENDOR RESPONSE

Red Hat Inc.:

"This issue affects the gtk2 packages as shipped with Red Hat Enterprise Linux 3 and 4, and the gdk-pixbuf packages as shipped with Red Hat Enterprise Linux 2.1, 3, and 4. Updates to these packages are available at the URL below or by using the Red Hat Network up2date tool. http://rhn.redhat.com/errata/CVE-2005-3186.html

This issue affects the gtk2 and gdk-pixbuf packages as shipped with Fedora Core 3 and 4."

VII. CVE INFORMATION

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

VIII. DISCLOSURE TIMELINE

10/12/2005 Initial vendor notification 10/14/2005 Initial vendor response 11/15/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.