heap-buffer-overflow /home/a13579/fuzz_lib_tiff/report/libtiff_asan/libtiff/tif_unix.c:362 in _TIFFmemset in branch 38a58201
Summary
heap-buffer-overflow /home/a13579/fuzz_lib_tiff/report/libtiff_asan/libtiff/tif_unix.c:362 in _TIFFmemset results in SIGSEGV
(Summarize the bug encountered concisely)
Version
a13579@13579 ~/f/report> libtiff/tools/tiffcrop -v
Library Release: LIBTIFF, Version 4.4.0
Copyright (c) 1988-1996 Sam Leffler
Copyright (c) 1991-1996 Silicon Graphics, Inc.
Tiffcrop version: 2.5.4, last updated: 27-08-2022
Tiffcp code: Copyright (c) 1988-1997 Sam Leffler
: Copyright (c) 1991-1997 Silicon Graphics, Inc
Tiffcrop additions: Copyright (c) 2007-2010 Richard Nolde
(libtiff version)
Steps to reproduce
$ git clone https://gitlab.com/libtiff/libtiff.git
$ cd libtiff/
$ ./autogen.sh
$ ./configure
$ make -j
$ ./tools/tiffcrop -Z 1:3,2:4 -e divided ./poc ./aa
TIFFReadDirectoryCheckOrder: Warning, Invalid TIFF directory; tags are not sorted in ascending order.
TIFFReadDirectory: Warning, Unknown field with tag 12336 (0x3030) encountered.
TIFFFetchNormalTag: Defined set_field_type of custom tag 12336 (Tag 12336) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFAdvanceDirectory: Error fetching directory count.
loadImage: Image lacks Photometric interpretation tag.
TIFFReadDirectoryCheckOrder: Warning, Invalid TIFF directory; tags are not sorted in ascending order.
TIFFReadDirectory: Warning, Unknown field with tag 12336 (0x3030) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 6712 (0x1a38) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 7330 (0x1ca2) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 7948 (0x1f0c) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 8566 (0x2176) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 9184 (0x23e0) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 9802 (0x264a) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 10420 (0x28b4) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 11038 (0x2b1e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 11656 (0x2d88) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 12274 (0x2ff2) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 12494 (0x30ce) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 206 (0xce) encountered.
TIFFFetchNormalTag: Defined set_field_type of custom tag 12336 (Tag 12336) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 6712 (Tag 6712) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 7330 (Tag 7330) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 7948 (Tag 7948) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 8566 (Tag 8566) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 9184 (Tag 9184) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 9802 (Tag 9802) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 10420 (Tag 10420) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 11038 (Tag 11038) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 11656 (Tag 11656) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 12274 (Tag 12274) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 12494 (Tag 12494) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 206 (Tag 206) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
loadImage: Image lacks Photometric interpretation tag.
fish: Job 1, './tools/tiffcrop -Z 1:3,2:4 -e…' terminated by signal SIGSEGV (Address boundary error)
(How one can reproduce the issue - this is very important)
Platform
a13579@13579 ~/f/r/libtiff (master)> gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
a13579@13579 ~/f/r/libtiff (master)> uname -r
5.15.0-50-generic
a13579@13579 ~/f/r/libtiff (master)> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
(Operating system, architecture, compiler details)
Asan report (compile with " ./configure CFLAGS='-fsanitize=address -g3' CXXFALGS='-fsanitize=address -g3' ")
a13579@13579 ~/f/report [SIGSEGV]> libtiff_asan/tools/tiffcrop -Z 1:3,2:4 -e divided poc /dev/null
TIFFReadDirectoryCheckOrder: Warning, Invalid TIFF directory; tags are not sorted in ascending order.
TIFFReadDirectory: Warning, Unknown field with tag 12336 (0x3030) encountered.
TIFFFetchNormalTag: Defined set_field_type of custom tag 12336 (Tag 12336) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFAdvanceDirectory: Error fetching directory count.
loadImage: Image lacks Photometric interpretation tag.
TIFFWriteDirectoryTagData: IO error writing tag data.
: Failed to write IFD for page number 0.
writeRegions: Unable to write new image.
TIFFReadDirectoryCheckOrder: Warning, Invalid TIFF directory; tags are not sorted in ascending order.
TIFFReadDirectory: Warning, Unknown field with tag 12336 (0x3030) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 6712 (0x1a38) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 7330 (0x1ca2) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 7948 (0x1f0c) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 8566 (0x2176) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 9184 (0x23e0) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 9802 (0x264a) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 10420 (0x28b4) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 11038 (0x2b1e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 11656 (0x2d88) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 12274 (0x2ff2) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 12494 (0x30ce) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 206 (0xce) encountered.
TIFFFetchNormalTag: Defined set_field_type of custom tag 12336 (Tag 12336) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 6712 (Tag 6712) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 7330 (Tag 7330) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 7948 (Tag 7948) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 8566 (Tag 8566) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 9184 (Tag 9184) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 9802 (Tag 9802) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 10420 (Tag 10420) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 11038 (Tag 11038) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 11656 (Tag 11656) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 12274 (Tag 12274) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 12494 (Tag 12494) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
TIFFFetchNormalTag: Defined set_field_type of custom tag 206 (Tag 206) is TIFF_SETGET_UNDEFINED and thus tag is not read from file.
loadImage: Image lacks Photometric interpretation tag.
=================================================================
==1794501==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62d000013a03 at pc 0x7f070adcbf3d bp 0x7ffeab2adb40 sp 0x7ffeab2ad2e8
WRITE of size 307203 at 0x62d000013a03 thread T0
#0 0x7f070adcbf3c in __interceptor_memset ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:762
#1 0x7f070acfa51b in _TIFFmemset /home/a13579/fuzz_lib_tiff/report/libtiff_asan/libtiff/tif_unix.c:362
#2 0x557305d40ef6 in processCropSelections /home/a13579/fuzz_lib_tiff/report/libtiff_asan/tools/tiffcrop.c:7826
#3 0x557305d23111 in main /home/a13579/fuzz_lib_tiff/report/libtiff_asan/tools/tiffcrop.c:2511
#4 0x7f070a7bf082 in __libc_start_main ../csu/libc-start.c:308
#5 0x557305d19b6d in _start (/home/a13579/fuzz_lib_tiff/report/libtiff_asan/tools/.libs/tiffcrop+0x9b6d)
0x62d000013a03 is located 0 bytes to the right of 38403-byte region [0x62d00000a400,0x62d000013a03)
allocated by thread T0 here:
#0 0x7f070ae71808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
#1 0x7f070acfa467 in _TIFFmalloc /home/a13579/fuzz_lib_tiff/report/libtiff_asan/libtiff/tif_unix.c:336
#2 0x557305d19d00 in limitMalloc /home/a13579/fuzz_lib_tiff/report/libtiff_asan/tools/tiffcrop.c:644
#3 0x557305d40d1b in processCropSelections /home/a13579/fuzz_lib_tiff/report/libtiff_asan/tools/tiffcrop.c:7803
#4 0x557305d23111 in main /home/a13579/fuzz_lib_tiff/report/libtiff_asan/tools/tiffcrop.c:2511
#5 0x7f070a7bf082 in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: heap-buffer-overflow ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:762 in __interceptor_memset
Shadow bytes around the buggy address:
0x0c5a7fffa6f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c5a7fffa700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c5a7fffa710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c5a7fffa720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c5a7fffa730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c5a7fffa740:[03]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c5a7fffa750: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c5a7fffa760: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c5a7fffa770: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c5a7fffa780: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c5a7fffa790: 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
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
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
Shadow gap: cc
==1794501==ABORTING
poc: poc