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 159
    • Issues 159
    • List
    • Boards
    • Service Desk
    • Milestones
    • Requirements
  • Merge requests 21
    • Merge requests 21
  • 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
  • #275
Closed
Open
Issue created Jun 22, 2021 by Doudou Huang@Shadowblade

Heap buffer overflow in reverseSamples16bits, tiffcrop.c

Summary

There is a heap buffer overflow in tiffcrop, reverseSamples16bits. tiffcrop.c, which could lead to denial of service.

Version

LIBTIFF, Version 4.3.0, commit 2a7f438d

Steps to reproduce

Compile with flag

-O0 -g -fsanitize=address

Run

./tiffcrop -i poc /dev/null

Here is the trace reported by ASAN:

==126173==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f2db3cfe97e at pc 0x000000524fee bp 0x7fffc6ad9050 sp 0x7fffc6ad9048
 READ of size 1 at 0x7f2db3cfe97e thread T0
     #0 0x524fed in reverseSamples16bits /mnt/data/playground/libtiff/build-bug/tools/../../tools/tiffcrop.c
     #1 0x5218f2 in mirrorImage /mnt/data/playground/libtiff/build-bug/tools/../../tools/tiffcrop.c:9142:33
     #2 0x4fccc1 in correct_orientation /mnt/data/playground/libtiff/build-bug/tools/../../tools/tiffcrop.c:6291:9
     #3 0x4fccc1 in main /mnt/data/playground/libtiff/build-bug/tools/../../tools/tiffcrop.c:2386:6
     #4 0x7f2db6ff183f in __libc_start_main /build/glibc-S7Ft5T/glibc-2.23/csu/../csu/libc-start.c:291
     #5 0x41c828 in _start (/mnt/data/playground/libtiff/build-bug/tools/tiffcrop+0x41c828)
 
 0x7f2db3cfe97e is located 11 bytes to the right of 1147251-byte region [0x7f2db3be6800,0x7f2db3cfe973)
 allocated by thread T0 here:
     #0 0x4afc22 in malloc /dependence/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145
     #1 0x5bf734 in _TIFFmalloc /mnt/data/playground/libtiff/build-bug/libtiff/../../libtiff/tif_unix.c:314:10
     #2 0x4fca92 in main /mnt/data/playground/libtiff/build-bug/tools/../../tools/tiffcrop.c:2376:11
     #3 0x7f2db6ff183f in __libc_start_main /build/glibc-S7Ft5T/glibc-2.23/csu/../csu/libc-start.c:291
 
 SUMMARY: AddressSanitizer: heap-buffer-overflow /mnt/data/playground/libtiff/build-bug/tools/../../tools/tiffcrop.c in reverseSamples16bits
 Shadow bytes around the buggy address:
   0x0fe636797cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0fe636797ce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0fe636797cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0fe636797d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0fe636797d10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 =>0x0fe636797d20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03[fa]
   0x0fe636797d30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0fe636797d40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0fe636797d50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0fe636797d60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0fe636797d70: 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
 ==126173==ABORTING

Platform

DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"

poc

Assignee
Assign to
Time tracking