ImageMagick mogrify buffer overflow vulnerability

October 21, 2016

A buffer overflow vulnerability(CVE-2016-7799)exists in ImageMagick.ImageMagick is used to create, edit, compose, or convert bitmap images.A buffer overflow exists in Imagemagick's mogrify command. The mogrify program is used to resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

Images have EXIF tags which are metadata containing focal lengths, exposures, dates, and in some cases GPS locations of the image file. When a image file with malformed EXIF tag is processed by ImageMagick mogrify program a buffer overflow occurs.This is because code in SyncExifProfile function,cannot handle the wrong EXIF tags.Successful exploitation could lead to arbitrary code execution.

Looking at the patch one can see the vulnerable SyncExifProfile function does not validate the EXIF values correctly.

The malformed data in the image file

Dell SonicWALL Threat Research Team has researched this vulnerability and released following signature to protect their customers.

  • SPY 1378 :Malformed-File jpg.TL.10
  • SPY 1386 :Malformed-File jpg.TL.11