out-of-bounds read in coders/pict.c:633 EncodeImage

Bug #1533449 reported by Moshe Kaplan on 2016-01-13
256
This bug affects 1 person
Affects Status Importance Assigned to Milestone
imagemagick (Ubuntu)
Undecided
Unassigned

Bug Description

This bug was found while fuzzing ImageMagick with afl-fuzz

Tested on ImageMagick version d8382f9c0ffa52057271a6a323e7e062f0fe4ff6

Command: magick infile /dev/null

Build info:

#Configure command:
CC=afl-clang-fast CXX=afl-clang-fast++ ./configure --with-bzlib=no --with-djvu=no --with-dps=no --with-fftw=no --with-fpx=no --with-fontconfig=no --with-freetype=no --with-gvc=no --with-jbig=no --with-jpeg=no --with-lcms=no --with-lqr=no --with-ltdl=no --with-lzma=no --with-openexr=no --with-openjp2=no --with-pango=no --with-png=no --with-tiff=no --with-wmf=no --with-x=no --with-xml=no --with-zlib=no --enable-hdri=no --enable-shared=no

#Make command:
CC=afl-clang-fast CXX=afl-clang-fast++ make

ASAN output:

=================================================================
==5220==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xb250a3ff at pc 0x86bb4a2 bp 0xbfe45278 sp 0xbfe45270
READ of size 1 at 0xb250a3ff thread T0
    #0 0x86bb4a1 in EncodeImage /home/user/Desktop/imagemagick_reporting/ImageMagick/coders/pict.c:633
    #1 0x86b88da in WritePICTImage /home/user/Desktop/imagemagick_reporting/ImageMagick/coders/pict.c:2006
    #2 0x8a96298 in WriteImage /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickCore/constitute.c:1091
    #3 0x8a99c7c in WriteImages /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickCore/constitute.c:1309
    #4 0x9375b7f in CLINoImageOperator /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickWand/operation.c:4697
    #5 0x937d98f in CLIOption /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickWand/operation.c:5157
    #6 0x910bea3 in ProcessCommandOptions /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickWand/magick-cli.c:526
    #7 0x910e325 in MagickImageCommand /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickWand/magick-cli.c:786
    #8 0x9112809 in MagickCommandGenesis /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickWand/mogrify.c:172
    #9 0x80de10d in MagickMain /home/user/Desktop/imagemagick_reporting/ImageMagick/utilities/magick.c:74
    #10 0x80de10d in main /home/user/Desktop/imagemagick_reporting/ImageMagick/utilities/magick.c:85
    #11 0xb7559a82 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287
    #12 0x80ddf34 in _start (/home/user/Desktop/imagemagick_reporting/ImageMagick/utilities/magick+0x80ddf34)

0xb250a3ff is located 1 bytes to the left of 32768-byte region [0xb250a400,0xb2512400)
allocated by thread T0 here:
    #0 0x80c6b61 in malloc (/home/user/Desktop/imagemagick_reporting/ImageMagick/utilities/magick+0x80c6b61)
    #1 0x81939e9 in AcquireMagickMemory /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickCore/memory.c:463
    #2 0x81939e9 in AcquireQuantumMemory /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickCore/memory.c:539
    #3 0x8a96298 in WriteImage /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickCore/constitute.c:1091
    #4 0x8a99c7c in WriteImages /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickCore/constitute.c:1309
    #5 0x9375b7f in CLINoImageOperator /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickWand/operation.c:4697
    #6 0x937d98f in CLIOption /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickWand/operation.c:5157
    #7 0x910bea3 in ProcessCommandOptions /home/user/Desktop/imagemagick_reporting/ImageMagick/MagickWand/magick-cli.c:526

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/user/Desktop/imagemagick_reporting/ImageMagick/coders/pict.c:633 EncodeImage
Shadow bytes around the buggy address:
  0x364a1420: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x364a1430: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x364a1440: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x364a1450: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x364a1460: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x364a1470: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
  0x364a1480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x364a1490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x364a14a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x364a14b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x364a14c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable: 00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone: fa
  Heap right redzone: fb
  Freed heap region: fd
  Stack left redzone: f1
  Stack mid redzone: f2
  Stack right redzone: f3
  Stack partial redzone: f4
  Stack after return: f5
  Stack use after scope: f8
  Global redzone: f9
  Global init order: f6
  Poisoned by user: f7
  ASan internal: fe
==5220==ABORTING

Moshe Kaplan (mk-moshe-kaplan) wrote :
information type: Private Security → Public Security
summary: - heap-buffer-overflow in coders/pict.c:633 EncodeImage
+ out-of-bounds read in coders/pict.c:633 EncodeImage
Moshe Kaplan (mk-moshe-kaplan) wrote :

Resolved upstream

Changed in imagemagick (Ubuntu):
status: New → Confirmed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package imagemagick - 8:6.9.6.6+dfsg-1ubuntu3

---------------
imagemagick (8:6.9.6.6+dfsg-1ubuntu3) zesty; urgency=medium

  * debian/patches/0020-Revert-GradientImage-change.patch: Revert patch
    per https://github.com/ImageMagick/ImageMagick/issues/316. Thanks
    to Cristy <email address hidden>. Closes LP: #1645406.

 -- Nishanth Aravamudan <email address hidden> Tue, 06 Dec 2016 17:26:36 +0100

Changed in imagemagick (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public Security information  Edit
Everyone can see this security related information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.