Bugzilla – Bug 64839
VUL-0: CVE-2005-0005: ImageMagick heap overflow
Last modified: 2021-10-27 11:47:14 UTC
We received the following report via vendor-sec. This issue is not public yet, please keep any information about it inside SUSE. Date: Thu, 13 Jan 2005 17:31:56 -0500 From: vendor-disclosure <vendor-disclosure@idefense.com> To: vendor-sec@lst.de Cc: vendor-disclosure <vendor-disclosure@idefense.com> Subject: [vendor-sec] iDEFENSE Security Advisory [IDEF0745] Multiple Unix/Linux Vendor ImageMagick .psd Image File Decode Heap Overflow Vulnerability The attached advisory will be released tomorrow. Please note the Vendor Response section of the advisory: VI. VENDOR RESPONSE Multiple unsuccessful attempts were made to inform ImageMagick.org about this vulnerability. As a result, a vendor patch is not available for this issue. Michael Sutton Director, iDEFENSE Labs Content-Description: pub_Multiple Unix Linux Vendor ImageMagick .psd Image File Decode Heap Overflow Vulnerability.TXT Multiple Unix/Linux Vendor ImageMagick .psd Image File Decode Heap Overflow Vulnerability iDEFENSE Security Advisory 01.13.05 http://www.idefense.com/application/poi/display?type=vulnerabilities January 13, 2005 I. BACKGROUND ImageMagick provides a variety of graphics image-handling libraries and capabilities. These libraries are widely used and are shipped by default on most Unix and Linux distributions. These libraries are commonly installed by default and on computers where any other graphical image viewer or X Desktop environment is installed (such as Gnome or KDE). More information is available at the following site: http://www.imagemagick.org II. DESCRIPTION Remote exploitation of a buffer overflow vulnerability in The ImageMagick's Project's ImageMagick PSD image-decoding module could allow an attacker to execute arbitrary code. A heap overflow exists within ImageMagick, specifically in the decoding of Photoshop Document (PSD) files. The vulnerable code follows: ImageMagick-6.1.0/coders/psd.c for (j=0; j < (long) layer_info[i].channels; j++) { layer_info[i].channel_info[j].type=(short)ReadBlobMSBShort(image); layer_info[i].channel_info[j].size=ReadBlobMSBLong(image); [...] } The array channel_info is only 24 elements large, and the loop variable, "j", is bounded by a user-supplied value from the image file, thus allowing a heap overflow to occur when more than 24 layers are specified. If heap structures are overflowed in a controlled way, execution of arbitrary code is possible. III. ANALYSIS Exploitation may allow attackers to run arbitrary code on a victim's computer if the victim opens a specially formatted image. Such images could be delivered by e-mail or HTML, in some cases, and would likely not raise suspicion on the victim's part. Exploitation is also possible when a web-based application uses ImageMagick to process user-uploaded image files. IV. DETECTION iDEFENSE has confirmed this vulnerability in ImageMagick 6.1.0 and ImageMagick 6.1.7. Earlier versions are also suspected vulnerable. The following vendors may include susceptible ImageMagick packages: The Debian Project MandrakeSoft Red Hat, Inc. V. WORKAROUND Do not open files from untrusted sources. Do not allow untrusted sources to process images using your web application. VI. VENDOR RESPONSE Multiple unsuccessful attempts were made to inform ImageMagick.org about this vulnerability. VII. CVE INFORMATION A Mitre Corp. Common Vulnerabilities and Exposures (CVE) number has not been assigned yet. VIII. DISCLOSURE TIMELINE 12/21/2004 Initial vendor notification 12/22/2004 Rejection notification received from the Magick-bugs mailing list 01/13/2005 Public disclosure IX. CREDIT Andrei Nigmatulin is credited with this discovery. Get paid for vulnerability research http://www.idefense.com/poi/teams/vcp.jsp X. LEGAL NOTICES Copyright ? 2004 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.
* This comment was added by mail. Date: Fri, 14 Jan 2005 11:39:15 +0100 From: Martin Schulze <joey@infodrom.org> To: Free Software Distribution Vendors <vendor-sec@lst.de> Subject: [vendor-sec] Re: iDEFENSE Security Advisory [IDEF0745] Multiple Unix/Linux Vendor ImageMagick .psd Image File Decode Heap Overflow Vulnerability vendor-disclosure wrote: | [...] There are two more similar loops that don't check the boundary of the channel_info array. The following patch should fix this as this seems to be the only place where the PSD file is read. --- psd.c~ 2002-03-26 03:26:03.000000000 +0100 +++ psd.c 2005-01-14 11:36:06.000000000 +0100 ThrowReaderException(CorruptImageWarning,"Not a PSD image file",image); (void) ReadBlob(image,6,(char *) psd_info.reserved); psd_info.channels=ReadBlobMSBShort(image); + if (psd_info.channels > 24) psd_info.channels = 24; psd_info.rows=ReadBlobMSBLong(image); psd_info.columns=ReadBlobMSBLong(image); psd_info.depth=ReadBlobMSBShort(image); Mark, if this vulnerability will indeed be disclosed tomorrow, could you assign a cve id for it? Regards, Joey
new CRD 17.01.2005
The patch is incomplete. There are two variables: psd_info.channels and layer_info[i].channels. It should look like this: --- coders/psd.c +++ coders/psd.c @@ -664,6 +664,7 @@ } (void) ReadBlob(image,6,psd_info.reserved); psd_info.channels=ReadBlobMSBShort(image); + if (psd_info.channels > 24) psd_info.channels = 24; psd_info.rows=ReadBlobMSBLong(image); psd_info.columns=ReadBlobMSBLong(image); psd_info.depth=ReadBlobMSBShort(image); @@ -846,6 +847,7 @@ layer_info[i].page.height=(ReadBlobMSBLong(image)-layer_info[i].page.y); layer_info[i].page.width=(ReadBlobMSBLong(image)-layer_info[i].page.x); layer_info[i].channels=ReadBlobMSBShort(image); + if (layer_info[i].channels > 24) layer_info[i].channels = 24; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule()," offset(%ld,%ld), size(%ld,%ld), channels=%d", layer_info[i].page.x, layer_info[i].page.y,
is public now.
Created attachment 27707 [details] mainstream patch
Packages are submitted. Can you please submit patchinfos?
CAN-2005-0005
updates released