CVE-2012-3438: Buffer Overflow
The Magickpngmalloc function in coders/png.c in GraphicsMagick 6.7.8-6 does not use the proper variable type for the allocation size, which might allow remote attackers to cause a denial of service (crash) via a crafted PNG file that triggers incorrect memory allocation.
Other sources
Tom Lane (tgl) found an issue in ImageMagick that is also present in GraphicsMagick. Basically CVE-2011-3026 deals with libpng memory allocation, limitations have been added so that a bad PNG can't cause the system to allocate a lot of memory causing a denial of service. However on further investigation of ImageMagick Tom Lane found that PNG malloc function (Magickpngmalloc) in turn calls AcquireMagickMemory with an improper size argument:
#ifdef PNGUSERMEMSUPPORTED static pngvoidp Magickpngmalloc(pngstructp pngptr,pnguint32 size) { (void) pngptr; return((pngvoidp) AcquireMagickMemory((sizet) size)); }
Similar code is present in GraphicsMagick:
#ifdef PNGUSERMEMSUPPORTED static pngvoidp pngIMmalloc(pngstructp pngptr,pnguint32 size) { (void) pngptr; return MagickAllocateMemory(pngvoidp,(sizet) size); }
This is incorrect, the size argument should be declared pngallocsizet according to 1.5, or pngsizet according to 1.2.
"As this function stands, it invisibly does the wrong thing for any request over 4GB. On big-endian architectures it very possibly will do the wrong thing even for requests less than that. So the reason why the hard-wired 4GB limit prevents a core dump is that it masks the ABI mismatch here."
So basically we have memory allocations problems that can probably lead to a denial of service.
Affected Software
Remediation
Patch Available
Event History
Frequently Asked Questions
What is the severity of CVE-2012-3438?
CVE-2012-3438 is classified as a denial-of-service vulnerability.
How do I fix CVE-2012-3438?
To fix CVE-2012-3438, upgrade GraphicsMagick to version 1.3.16 or later.
What causes CVE-2012-3438?
CVE-2012-3438 is caused by improper allocation size in the Magick_png_malloc function, which can lead to application crashes with specially crafted PNG files.
Which versions of GraphicsMagick are affected by CVE-2012-3438?
GraphicsMagick versions prior to 1.3.16 are affected by CVE-2012-3438.
Can CVE-2012-3438 be exploited remotely?
Yes, CVE-2012-3438 can be exploited remotely through malicious PNG files.