out-of-bounds read in MagickCore/property.c:1396 could lead to memory leak
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
imagemagick (Ubuntu) |
Confirmed
|
Medium
|
Unassigned |
Bug Description
This bug was found while fuzzing ImageMagick with afl-fuzz
command: magick identify PoC.jpg
The vulnerability could lead to information leakage because the pointer is used later to read data from the memory
MagickCore/
MagickCore/
The code basically reads the number of entries inside directory object in an image
MagickCore/
By manipulating bytes at position 0x76 and 0x77 in the PoC image, we can control number_entries variable which is used to in the loop. By controlling number_entries we can partially control q
MagickCore/
In the previous line we control the value of "entry". As a result, we can partially control q which can be used later to read arbitrary data from the process of ImageMagick.
PoC image: https:/
[backtrace]
storm@storm ~/f/f/f/crashes> gdb -q magick core.magick.14585
Reading symbols from magick...done.
[New LWP 14585]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_
Core was generated by `magick identify PoC.jpg'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007f110bac6c37 in __GI_raise (sig=sig@entry=6) at ../nptl/
56 ../nptl/
(gdb) bt
#0 0x00007f110bac6c37 in __GI_raise (sig=sig@entry=6) at ../nptl/
#1 0x00007f110baca028 in __GI_abort () at abort.c:89
#2 0x0000000000421b5b in MagickSignalHandler (signal_number=6) at MagickCore/
#3 <signal handler called>
#4 0x00007f110bac6c37 in __GI_raise (sig=sig@entry=6) at ../nptl/
#5 0x00007f110baca028 in __GI_abort () at abort.c:89
#6 0x0000000000421b5b in MagickSignalHandler (signal_number=11) at MagickCore/
#7 <signal handler called>
#8 ReadPropertySig
endian=
#9 GetEXIFProperty (image=
exception=
#10 0x000000000043e4d8 in GetImageProperty (image=
property=
at MagickCore/
#11 0x0000000000441d03 in SetImageProfile
name=
recursive=
#12 0x000000000044297a in SetImageProfile (image=
profile=
#13 0x000000000053c922 in ReadProfile (jpeg_info=
#14 0x00007f1110464975 in ?? () from /usr/lib/
#15 0x00007f11104629ca in ?? () from /usr/lib/
#16 0x00007f111045cf57 in jpeg_consume_input () from /usr/lib/
#17 0x00007f111045d223 in jpeg_read_header () from /usr/lib/
#18 0x000000000053d669 in ReadJPEGImage (image_
#19 0x00000000005a06ee in ReadImage (image_
exception=
#20 0x0000000000677326 in ReadStream (image_
stream=
#21 0x00000000005a0261 in PingImage (image_
---Type <return> to continue, or q <return> to quit---
exception=
#22 0x00000000005a04ab in PingImages (image_
filename=
at MagickCore/
#23 0x00000000006f2741 in IdentifyImageCo
argc=
exception=
#24 0x000000000071a274 in MagickCommandGe
command=
metadata=
#25 0x0000000000411f11 in MagickMain (argc=2, argv=0x7ffe5d18
#26 0x00007f110bab1f45 in __libc_start_main (main=0x40ec10 <main>, argc=3, argv=0x7ffe5d18
init=<optimised out>, fini=<optimised out>, rtld_fini=
at libc-start.c:287
#27 0x0000000000411af5 in _start ()
The current PoC sets the number_entries to 0xffff (12*entry) +2 and entry is 0xffff * 12 then q is outside the memory space
when q = (directory+