Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • L libtiff
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 157
    • Issues 157
    • List
    • Boards
    • Service Desk
    • Milestones
    • Requirements
  • Merge requests 20
    • Merge requests 20
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • libtiff
  • libtiff
  • Issues
  • #498
Closed
Open
Issue created Dec 07, 2022 by 4ugustus@waugustusContributor

tiffcrop: heap-buff-overflow in _TIFFmemcpy, tif_unix.c:368, different from #495

Summary

There is heap-buffer-overflow errors in _TIFFmemcpy in libtiff/tif_unix.c:368. Remote attackers could leverage this vulnerability to cause a denial-of-service via a crafted tiff file. Note that this is different from #495 (closed)

Version

LIBTIFF, Version master (post 4.4.0), commit id 1bdbd03f (Tue Nov 29 17:02:09 2022 +0000)

Steps to reproduce

# CFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" CXXFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" ./configure --prefix=$PWD/build_asan --disable-shared

# make -j; make install; make clean

$ ./build_asan/bin/tiffcrop -E right -z 1,1,2048,2048:1,2049,2048,4097 -i poc /tmp/foo
TIFFReadDirectoryCheckOrder: Warning, Invalid TIFF directory; tags are not sorted in ascending order.
TIFFSetField: poc_346_2: Invalid InkNames value; no NUL at given buffer end location 0, after 0 ink.
TIFFReadDirectory: Warning, Ignoring ColorMap because BitsPerSample=128>24.
=================================================================
==145275==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x629000009a00 at pc 0x7f2391e0d58d bp 0x7ffe3c094ef0 sp 0x7ffe3c094698
WRITE of size 512 at 0x629000009a00 thread T0
    #0 0x7f2391e0d58c in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:790
    #1 0x5606b0805184 in _TIFFmemcpy /root/programs_latest/libtiff/libtiff/tif_unix.c:368
    #2 0x5606b076dd16 in extractContigSamplesBytes /root/programs_latest/libtiff/tools/tiffcrop.c:2903
    #3 0x5606b0785162 in extractCompositeRegions /root/programs_latest/libtiff/tools/tiffcrop.c:6778
    #4 0x5606b0788d0a in processCropSelections /root/programs_latest/libtiff/tools/tiffcrop.c:7733
    #5 0x5606b076bbb1 in main /root/programs_latest/libtiff/tools/tiffcrop.c:2511
    #6 0x7f23914d7082 in __libc_start_main ../csu/libc-start.c:308
    #7 0x5606b076260d in _start (/root/programs_latest/libtiff/build_asan/bin/tiffcrop+0x2e60d)

0x629000009a00 is located 509 bytes to the right of 17923-byte region [0x629000005200,0x629000009803)
allocated by thread T0 here:
    #0 0x7f2391e7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5606b080509e in _TIFFmalloc /root/programs_latest/libtiff/libtiff/tif_unix.c:336
    #2 0x5606b07627a0 in limitMalloc /root/programs_latest/libtiff/tools/tiffcrop.c:644
    #3 0x5606b0788a81 in processCropSelections /root/programs_latest/libtiff/tools/tiffcrop.c:7705
    #4 0x5606b076bbb1 in main /root/programs_latest/libtiff/tools/tiffcrop.c:2511
    #5 0x7f23914d7082 in __libc_start_main ../csu/libc-start.c:308

SUMMARY: AddressSanitizer: heap-buffer-overflow ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:790 in __interceptor_memcpy
Shadow bytes around the buggy address:
  0x0c527fff92f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c527fff9300: 03 fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c527fff9310: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c527fff9320: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c527fff9330: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c527fff9340:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c527fff9350: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c527fff9360: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c527fff9370: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c527fff9380: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c527fff9390: 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
==145275==ABORTING

Platform

# uname -a
Linux dd189b3c7b86 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

poc.zip

Assignee
Assign to
Time tracking