SEGV in 8BIM profile in ImageMagick-6.8.9-8
Posted: 2014-10-04T06:25:31-07:00
Hi,
I've been fuzzing ImageMagick and came across the following segfault. I am fuzzing conversion of jpg to png.
cmdline:
works: original jpg file: https://www.dropbox.com/s/uhamfas94fpfg ... 4.jpg?dl=0
SEGV example 1: fuzzed file 1, error in offset 4473: https://www.dropbox.com/s/6gu8gnkstsbuy ... A4473?dl=0
SEGV example 2: fuzzed file 2, error in offset 4503: https://www.dropbox.com/s/uonooyi5ys6w1 ... A4503?dl=0
bt:
context:
I don't know much about C programming, so I'll leave the fix up to you. I hope it's something simple like p wrapping around in GetProfilesFromResourceBlock.
I've been fuzzing ImageMagick and came across the following segfault. I am fuzzing conversion of jpg to png.
cmdline:
Code: Select all
lt-convert ./id:000001,src:000002,op:flip1,pos:4473 png:/dev/null
SEGV example 1: fuzzed file 1, error in offset 4473: https://www.dropbox.com/s/6gu8gnkstsbuy ... A4473?dl=0
SEGV example 2: fuzzed file 2, error in offset 4503: https://www.dropbox.com/s/uonooyi5ys6w1 ... A4503?dl=0
bt:
Code: Select all
#0 0xb62e23a7 in raise () from /lib/i386-linux-gnu/libc.so.6
#1 0xb62e5792 in abort () from /lib/i386-linux-gnu/libc.so.6
#2 0xb71dd0eb in MagickSignalHandler (signal_number=0x6) at magick/magick.c:1171
#3 <signal handler called>
#4 0xb62e23a7 in raise () from /lib/i386-linux-gnu/libc.so.6
#5 0xb62e5792 in abort () from /lib/i386-linux-gnu/libc.so.6
#6 0xb71dd0eb in MagickSignalHandler (signal_number=0xb) at magick/magick.c:1171
#7 <signal handler called>
#8 0xb63327db in strncasecmp () from /lib/i386-linux-gnu/libc.so.6
#9 0xb734b8ca in LocaleNCompare (p=p@entry=0x8f2c28a <Address 0x8f2c28a out of bounds>, q=q@entry=0xb7630472 "8BIM", length=length@entry=0x4) at magick/string.c:1642
#10 0xb72495ef in GetProfilesFromResourceBlock (resource_block=0x9126458, image=0x9117788) at magick/profile.c:1564
#11 SetImageProfileInternal (image=0x9117788, name=0xb7635efb "8bim", profile=0x9126458, recursive=MagickFalse) at magick/profile.c:1732
#12 0xb724a447 in SetImageProfile (image=0x9126458, image@entry=0x9117788, name=0x0, name@entry=0xb7635efb "8bim", profile=profile@entry=0x9126458) at magick/profile.c:1747
#13 0xb75c82da in ReadIPTCProfile (jpeg_info=0xbfb7fb9c) at coders/jpeg.c:597
#14 0xb6c0968b in ?? () from /usr/lib/i386-linux-gnu/libjpeg.so.8
#15 0xb6c06d2e in ?? () from /usr/lib/i386-linux-gnu/libjpeg.so.8
#16 0xb6bff927 in jpeg_consume_input () from /usr/lib/i386-linux-gnu/libjpeg.so.8
#17 0xb6bffba3 in jpeg_read_header () from /usr/lib/i386-linux-gnu/libjpeg.so.8
#18 0xb75ca6fe in ReadJPEGImage (image_info=0x90f5798, exception=0x90ea318) at coders/jpeg.c:1071
#19 0xb705b6de in ReadImage (image_info=image_info@entry=0x90f1690, exception=exception@entry=0x90ea318) at magick/constitute.c:492
#20 0xb705e1f1 in ReadImages (image_info=image_info@entry=0x90f1690, exception=exception@entry=0x90ea318) at magick/constitute.c:853
#21 0xb6dd4a4d in ConvertImageCommand (image_info=0x90f1690, argc=0x3, argv=0x90eb3e8, metadata=0x0, exception=0x90ea318) at wand/convert.c:619
#22 0xb6eaf546 in MagickCommandGenesis (image_info=0x90ed588, command=0x80488f0 <ConvertImageCommand@plt>, argc=0x3, argv=0xbfb895c4, metadata=0x0, exception=0x90ea318) at wand/mogrify.c:168
#23 0x08048aa5 in ConvertMain (argv=0xbfb895c4, argc=0x3) at utilities/convert.c:81
#24 main (argc=0x3, argv=0xbfb895c4) at utilities/convert.c:92
Code: Select all
_______________________________________________________________________________
eax:00000000 ebx:00003685 ecx:00003685 edx:00000006 eflags:00000202
esi:00000006 edi:B6401FF4 esp:BFB7BC98 ebp:BFB7BCA0 eip:B62E23A7
cs:0073 ds:007B es:007B fs:0000 gs:0033 ss:007B o d I t s z a p c
[007B:BFB7BC98]---------------------------------------------------------[stack]
BFB7BCC8 : 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................
BFB7BCB8 : 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................
BFB7BCA8 : 06 00 00 00 40 BD B7 BF - 00 00 00 00 00 00 00 00 ....@...........
BFB7BC98 : F4 1F 40 B6 C0 BD B7 BF - C8 BD B7 BF 92 57 2E B6 ..@..........W..
[007B:B6401FF4]---------------------------------------------------------[ data]
B6401FF4 : 7C 9D 14 00 C0 F2 41 B6 - B0 19 7D B7 06 EC 2C B6 |.....A...}...,.
B6402004 : 16 EC 2C B6 20 D2 32 B6 - 36 EC 2C B6 46 EC 2C B6 ..,. .2.6.,.F.,.
[0073:B62E23A7]---------------------------------------------------------[ code]
=> 0xb62e23a7 <raise+71>: xchg %edi,%ebx
0xb62e23a9 <raise+73>: cmp $0xfffff000,%eax
0xb62e23ae <raise+78>: ja 0xb62e23d2 <raise+114>
0xb62e23b0 <raise+80>: mov (%esp),%ebx
0xb62e23b3 <raise+83>: mov 0x4(%esp),%edi
0xb62e23b7 <raise+87>: mov %ebp,%esp
------------------------------------------------------------------------------