Skip to content
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

heap_buffer_overflow in WriteTIFFImage of coders/tiff.c #1555

Closed
3 tasks done
galycannon opened this issue Apr 27, 2019 · 2 comments
Closed
3 tasks done

heap_buffer_overflow in WriteTIFFImage of coders/tiff.c #1555

galycannon opened this issue Apr 27, 2019 · 2 comments
Labels
Milestone

Comments

@galycannon
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am using the latest version of ImageMagick
  • I have searched open and closed issues to ensure it has not already been reported

Description

There is a heap buffer overflow vulnerability in function WriteTIFFImage of coders/tiff.c.

Steps to Reproduce

poc
magick convert $poc /dev/null
=================================================================
==2369==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000ab14 at pc 0x7f24afc30935 bp 0x7ffe0bdcba20 sp 0x7ffe0bdcb1c8
READ of size 131072 at 0x60200000ab14 thread T0
#0 0x7f24afc30934 in __asan_memcpy (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x8c934)
#1 0x7f24af23823a (/usr/lib/x86_64-linux-gnu/libtiff.so.5+0x1823a)
#2 0x7a3fed in WriteTIFFImage coders/tiff.c:4314
#3 0x848ecb in WriteImage MagickCore/constitute.c:1159
#4 0x849bf0 in WriteImages MagickCore/constitute.c:1376
#5 0xbf1565 in ConvertImageCommand MagickWand/convert.c:3305
#6 0xcdf015 in MagickCommandGenesis MagickWand/mogrify.c:185
#7 0x4100a1 in MagickMain utilities/magick.c:149
#8 0x410282 in main utilities/magick.c:180
#9 0x7f24ab49d82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#10 0x40fbb8 in _start (/home/ImageMagick/utilities/magick+0x40fbb8)
`0x60200000ab14 is located 0 bytes to the right of 4-byte region [0x60200000ab10,0x60200000ab14)` `allocated by thread T0 here:` ` #0 0x7f24afc3c602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)` ` #1 0x7f24af2293d4 (/usr/lib/x86_64-linux-gnu/libtiff.so.5+0x93d4)`
SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 __asan_memcpy
Shadow bytes around the buggy address:
0x0c047fff9510: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff9520: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff9530: fa fa fa fa fa fa fa fa fa fa fd fa fa fa fd fa
0x0c047fff9540: fa fa fd fa fa fa fd fd fa fa fd fd fa fa fd fa
0x0c047fff9550: fa fa fd fa fa fa fd fa fa fa 04 fa fa fa 04 fa
=>0x0c047fff9560: fa fa[04]fa fa fa 00 fa fa fa fd fd fa fa fd fd
0x0c047fff9570: fa fa 00 00 fa fa fd fa fa fa fd fa fa fa fd fa
0x0c047fff9580: fa fa 00 fa fa fa 00 fa fa fa fd fa fa fa fd fd
0x0c047fff9590: fa fa 00 04 fa fa 00 04 fa fa 00 04 fa fa 00 04
0x0c047fff95a0: fa fa 00 04 fa fa 00 04 fa fa 00 07 fa fa 03 fa
0x0c047fff95b0: fa fa 00 03 fa fa 00 04 fa fa fd fd fa fa fd fd
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
==2369==ABORTING

System Configuration

  • ImageMagick version:
    Version: ImageMagick 7.0.8-43 Q16 x86_64 2019-04-27 https://imagemagick.org
    Copyright: ? 1999-2019 ImageMagick Studio LLC
    License: https://imagemagick.org/script/license.php
    Features: Cipher DPC HDRI OpenMP(4.0)
    Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr lzma openexr pangocairo png tiff wmf x xml zlib
  • Environment (Operating system, version and so on):
    Distributor ID: Ubuntu
    Description: Ubuntu 16.04.1 LTS
    Release: 16.04
    Codename: xenial
  • Additional information:
urban-warrior pushed a commit to ImageMagick/ImageMagick6 that referenced this issue Apr 27, 2019
@urban-warrior
Copy link
Member

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 @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

@dlemstra dlemstra added the bug label Apr 28, 2019
@dlemstra dlemstra added this to the 7.0.8-43 milestone Apr 28, 2019
dlemstra added a commit to ImageMagick/ImageMagick6 that referenced this issue Apr 28, 2019
@dlemstra
Copy link
Member

To the person that created CVE-2019-11597 based on this issue. The milestone 7.0.8-43 is the version where this gets fixed not the version that contains this bug. Seen this happen a couple times now.

@dlemstra dlemstra closed this as completed May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants