GraphicsMagick Memory Disclosure / Heap Overflow
Posted on 04 November 2017
'''Vulnerabilities summary The following advisory describes two (2) vulnerabilities found in GraphicsMagick. GraphicsMagick is aThe swiss army knife of image processing. Comprised of 267K physical lines (according to David A. Wheeleras SLOCCount) of source code in the base package (or 1,225K including 3rd party libraries) it provides a robust and efficient collection of tools and libraries which support reading, writing, and manipulating an image in over 88 major formats including important formats like DPX, GIF, JPEG, JPEG-2000, PNG, PDF, PNM, and TIFF.a The vulnerabilities found are: Memory Information Disclosure Heap Overflow Credit An independent security researchers, Jeremy Heng (@nn_amon) and Terry Chia (Ayrx), has reported this vulnerability to Beyond Securityas SecuriTeam Secure Disclosure program Vendor response The vendor has released patches to address these vulnerabilities (15237:e4e1c2a581d8 and 15238:7292230dd18). For more details: ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/snapshots/ChangeLog.txt Vulnerabilities details Memory Information Disclosure GraphicsMagick is vulnerable to a memory information disclosure vulnerability found in DescribeImage function of the magick/describe.c file. The portion of the code containing the vulnerability responsible of printing the IPTC Profile information contained in the image. This vulnerability can be triggered with a specially crafted MIFF file. The code which triggers the vulnerable code path is: 63 MagickExport MagickPassFail DescribeImage(Image *image,FILE *file, 64 const MagickBool verbose) 65 { ... 660 for (i=0; i < profile_length; ) 661 { 662 if (profile[i] != 0x1c) 663 { 664 i++; 665 continue; 666 } 667 i++; /* skip file separator */ 668 i++; /* skip record number */ ... 725 i++; 726 (void) fprintf(file," %.1024s: ",tag); 727 length=profile[i++] << 8; 728 length|=profile[i++]; 729 text=MagickAllocateMemory(char *,length+1); 730 if (text != (char *) NULL) 731 { 732 char 733 **textlist; 734 735 register unsigned long 736 j; 737 738 (void) strncpy(text,(char *) profile+i,length); 739 text[length]='