Skip to content

imagemagick mogrify heap use after free #281

Closed
@marcograss

Description

@marcograss

Hi, the following test case will reproduce this crash. It's attached, you need a ASAN build on master branch

➜ utilities git:(master) ✗ ./magick mogrify ../../ImageMagick_bugs/mogrify_heap_uaf

==26427==ERROR: AddressSanitizer: heap-use-after-free on address 0x60600003c868 at pc 0x0000016cfeba bp 0x7ffdebb9ff70 sp 0x7ffdebb9ff68
READ of size 4 at 0x60600003c868 thread T0
#0 0x16cfeb9 (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x16cfeb9)
#1 0x16383cf (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x16383cf)
#2 0x18bfcfc (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x18bfcfc)
#3 0x18c2594 (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x18c2594)
#4 0x2ff1c7f (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x2ff1c7f)
#5 0x2f8cead (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x2f8cead)
#6 0x4f5da9 (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x4f5da9)
#7 0x7f773a59e82f (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#8 0x422428 (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x422428)

0x60600003c868 is located 8 bytes inside of 56-byte region [0x60600003c860,0x60600003c898)
freed by thread T0 here:
#0 0x4c23d0 (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x4c23d0)
#1 0x5ac708 (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x5ac708)

previously allocated by thread T0 here:
#0 0x4c2558 (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x4c2558)
#1 0x55c149 (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x55c149)

SUMMARY: AddressSanitizer: heap-use-after-free (/home/bob/VulnResearch/misc/ImageMagick/utilities/magick+0x16cfeb9)
Shadow bytes around the buggy address:
0x0c0c7ffff8b0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fa
0x0c0c7ffff8c0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
0x0c0c7ffff8d0: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
0x0c0c7ffff8e0: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
0x0c0c7ffff8f0: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
=>0x0c0c7ffff900: 00 00 00 00 00 00 00 00 fa fa fa fa fd[fd]fd fd
0x0c0c7ffff910: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
0x0c0c7ffff920: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
0x0c0c7ffff930: fd fd fd fd fd fd fd fa fa fa fa fa fd fd fd fd
0x0c0c7ffff940: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fa
0x0c0c7ffff950: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
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
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==26427==ABORTING

Thanks

marco

mogrify_heap_uaf.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions