New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak in ReadMATImage #734

Closed
bestshow opened this Issue Sep 6, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@bestshow

bestshow commented Sep 6, 2017

Version: ImageMagick 7.0.7-1 Q16 x86_64

A memory leak vulnerability was found in function ReadMATImage in coders/mat.c ,which allow attackers to cause a denial of service via a crafted file.

#./identify $FILE
=================================================================
==106216==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 13488 byte(s) in 1 object(s) allocated from:
    #0 0x4ec5a6 in __interceptor_malloc /home/test/Downloads/llvm-clang/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:66
    #1 0x527f7c in AcquireImage /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/image.c:169:19
    #2 0x8da29b in decompress_block /home/test/Downloads/IM-afl/ImageMagick-master/coders/mat.c:570:17
    #3 0x8da29b in ReadMATImage /home/test/Downloads/IM-afl/ImageMagick-master/coders/mat.c:966
    #4 0xdf8370 in ReadImage /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/constitute.c:497:13
    #5 0x133293d in ReadStream /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/stream.c:1045:9
    #6 0xdf6f15 in PingImage /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/constitute.c:226:9
    #7 0x1675c56 in IdentifyImageCommand /home/test/Downloads/IM-afl/ImageMagick-master/MagickWand/identify.c:319:18
    #8 0x174b360 in MagickCommandGenesis /home/test/Downloads/IM-afl/ImageMagick-master/MagickWand/mogrify.c:183:14
    #9 0x522919 in MagickMain /home/test/Downloads/IM-afl/ImageMagick-master/utilities/magick.c:149:10
    #10 0x522919 in main /home/test/Downloads/IM-afl/ImageMagick-master/utilities/magick.c:180
    #11 0x7f1676664b34 in __libc_start_main /usr/src/debug/glibc-2.17-c758a686/csu/../csu/libc-start.c:274

Indirect leak of 13024 byte(s) in 1 object(s) allocated from:
    #0 0x4ec5a6 in __interceptor_malloc /home/test/Downloads/llvm-clang/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:66
    #1 0x52c705 in AcquireImageInfo /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/image.c:347:28
    #2 0x52934d in AcquireImage /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/image.c:290:10
    #3 0x8da29b in decompress_block /home/test/Downloads/IM-afl/ImageMagick-master/coders/mat.c:570:17
    #4 0x8da29b in ReadMATImage /home/test/Downloads/IM-afl/ImageMagick-master/coders/mat.c:966
    #5 0xdf8370 in ReadImage /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/constitute.c:497:13
    #6 0x133293d in ReadStream /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/stream.c:1045:9
    #7 0xdf6f15 in PingImage /home/test/Downloads/IM-afl/ImageMagick-master/MagickCore/constitute.c:226:9
    #8 0x1675c56 in IdentifyImageCommand /home/test/Downloads/IM-afl/ImageMagick-master/MagickWand/identify.c:319:18
    #9 0x174b360 in MagickCommandGenesis /home/test/Downloads/IM-afl/ImageMagick-master/MagickWand/mogrify.c:183:14
    #10 0x522919 in MagickMain /home/test/Downloads/IM-afl/ImageMagick-master/utilities/magick.c:149:10
    #11 0x522919 in main /home/test/Downloads/IM-afl/ImageMagick-master/utilities/magick.c:180
    #12 0x7f1676664b34 in __libc_start_main /usr/src/debug/glibc-2.17-c758a686/csu/../csu/libc-start.c:274
......
46393 byte(s) leaked in 21 allocation(s).

testcase:https://github.com/bestshow/p0cs/blob/master/memory_leak_in_ReadMATImage966_x.mat
Credit:ADLab of Venustech

@mikayla-grace

This comment has been minimized.

Show comment
Hide comment
@mikayla-grace

mikayla-grace Sep 6, 2017

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.

mikayla-grace commented Sep 6, 2017

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.

urban-warrior pushed a commit that referenced this issue Sep 6, 2017

urban-warrior pushed a commit that referenced this issue Sep 6, 2017

@dlemstra dlemstra added the bug label Sep 6, 2017

@dlemstra dlemstra closed this Sep 6, 2017

@nohmask

This comment has been minimized.

Show comment
Hide comment
@nohmask

nohmask Jan 15, 2018

This was assigned CVE-2017-18027.

nohmask commented Jan 15, 2018

This was assigned CVE-2017-18027.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment