Bug 2686 - tiffcrop.c:3911:heap buffer overflow in combineSeparateSamples16bits
: tiffcrop.c:3911:heap buffer overflow in combineSeparateSamples16bits
Status: RESOLVED LATER
: libtiff
default
: unspecified
: PC Linux
: P1 critical
: ---
Assigned To:
:
:
: migrated_to_gitlab
:
:
  Show dependency treegraph
 
Reported: 2017-04-20 12:07 by
Modified: 2019-10-01 14:20 (History)


Attachments
testcase (5.00 KB, image/tiff)
2017-04-20 12:07, bestshow
Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2017-04-20 12:07:09
Created an attachment (id=767) [details]
testcase

on libtiff 4.0.7

The combineSeparateSamples16bits function in tiffcrop.c:3911 allows remote
attackers to cause a denial of service (heap buffer overflow) via a crafted
file.

#tiffcrop $FILE out.tif
=================================================================
==25991==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61b00001f7b7 at pc 0x000000410343 bp 0x7fff0cafe240 sp 0x7fff0cafe238
READ of size 1 at 0x61b00001f7b7 thread T0
    #0 0x410342 in combineSeparateSamples16bits
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiffcrop.c:3911
    #1 0x4156aa in readSeparateStripsIntoBuffer
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiffcrop.c:4881
    #2 0x41ebcb in loadImage
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiffcrop.c:6175
    #3 0x40a743 in main
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiffcrop.c:2345
    #4 0x7fca255e7b34 in __libc_start_main (/lib64/libc.so.6+0x21b34)
    #5 0x402e28 
(/home/haojun/Downloads/testopensourcecode/tiff-4.0.7_build/bin/tiffcrop+0x402e28)

0x61b00001f7b7 is located 0 bytes to the right of 1591-byte region
[0x61b00001f180,0x61b00001f7b7)
allocated by thread T0 here:
    #0 0x7fca263dbbb8 in __interceptor_malloc
../../../../libsanitizer/asan/asan_malloc_linux.cc:62
    #1 0x486286 in _TIFFmalloc
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/libtiff/tif_unix.c:316
    #2 0x4150a2 in readSeparateStripsIntoBuffer
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiffcrop.c:4821
    #3 0x41ebcb in loadImage
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiffcrop.c:6175
    #4 0x40a743 in main
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiffcrop.c:2345
    #5 0x7fca255e7b34 in __libc_start_main (/lib64/libc.so.6+0x21b34)

SUMMARY: AddressSanitizer: heap-buffer-overflow
/home/haojun/Downloads/testopensourcecode/tiff-4.0.7/tools/tiffcrop.c:3911 in
combineSeparateSamples16bits
Shadow bytes around the buggy address:
  0x0c367fffbea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c367fffbeb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c367fffbec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c367fffbed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c367fffbee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c367fffbef0: 00 00 00 00 00 00[07]fa fa fa fa fa fa fa fa fa
  0x0c367fffbf00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c367fffbf10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c367fffbf20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c367fffbf30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c367fffbf40: fa fa fa fa fa fa fa fa fa fa fa 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
==25991==ABORTING

testcase:https://github.com/bestshow/p0cs/blob/master/heap-buffer-overflow-combineSeparateSamples16bits-tiffcrop-3.tif
------- Comment #1 From 2017-05-24 04:07:39 -------
this looks to be a duplicate of 2621

Please check if all your reported bugs are a duplicate of existing bugs. Feel
free to test also with newer 4.0.8
------- Comment #2 From 2019-10-01 14:20:33 -------
Bugzilla is no longer used for tracking libtiff issues. Remaining open tickets,
such as this one, have been migrated to the libtiff GitLab instance at
https://gitlab.com/libtiff/libtiff/issues .

The migrated tickets have their summary prefixed with [BZ#XXXX] where XXXX is
the initial Bugzilla issue number.