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

AddressSanitizer: heap-buffer-overflow in RafImage::readMetadata #952

Closed
cuanduo opened this issue Jul 12, 2019 · 4 comments
Closed

AddressSanitizer: heap-buffer-overflow in RafImage::readMetadata #952

cuanduo opened this issue Jul 12, 2019 · 4 comments
Labels
bug notReproducible Reported bugs not confirmed

Comments

@cuanduo
Copy link

cuanduo commented Jul 12, 2019

Describe the bug
in my research , a heap overflow found in RafImage::readMetadata rafimage.cpp:296.

To Reproduce
exiv2 -pv $poc
exiv2poc.zip

Expected behavior

root@ubuntu:~/fuzz/exiv2# /home/tim/exiv2-asan/build/bin/exiv2  /home/tim/fuzz/exiv2/out/master/queue/id:000174,src:000124,op:ext_AO,pos:24,+cov
=================================================================
==108944==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000001b4 at pc 0x7f55a6829733 bp 0x7ffeff406e20 sp 0x7ffeff4065c8
READ of size 4 at 0x6030000001b4 thread T0
    #0 0x7f55a6829732  (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x79732)
    #1 0x7f55a5dc4723 in memcpy /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
    #2 0x7f55a5dc4723 in Exiv2::MemIo::read(unsigned char*, unsigned long) /home/tim/exiv2-asan/src/basicio.cpp:1354
    #3 0x7f55a5f65c98 in Exiv2::RafImage::readMetadata() /home/tim/exiv2-asan/src/rafimage.cpp:296
    #4 0x7f55a5f0fa9c in Exiv2::PgfImage::readMetadata() /home/tim/exiv2-asan/src/pgfimage.cpp:153
    #5 0x5636c0fbc644 in Action::Print::printSummary() /home/tim/exiv2-asan/src/actions.cpp:260
    #6 0x5636c0fc1304 in Action::Print::run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/tim/exiv2-asan/src/actions.cpp:215
    #7 0x5636c0f39692 in main /home/tim/exiv2-asan/src/exiv2.cpp:77
    #8 0x7f55a526db96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #9 0x5636c0f3a359 in _start (/home/tim/exiv2-asan/build/bin/exiv2+0x18359)

0x6030000001b4 is located 12 bytes to the right of 24-byte region [0x603000000190,0x6030000001a8)
allocated by thread T0 here:
    #0 0x7f55a6890458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
    #1 0x7f55a5eb05e9 in Exiv2::ImageFactory::open(unsigned char const*, unsigned long) /home/tim/exiv2-asan/src/image.cpp:902

SUMMARY: AddressSanitizer: heap-buffer-overflow (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x79732) 
Shadow bytes around the buggy address:
  0x0c067fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c067fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c067fff8000: fa fa fd fd fd fd fa fa 00 00 00 06 fa fa fd fd
  0x0c067fff8010: fd fa fa fa fd fd fd fd fa fa fd fd fd fd fa fa
  0x0c067fff8020: 00 00 00 00 fa fa 00 00 00 fa fa fa 00 00 00 06
=>0x0c067fff8030: fa fa 00 00 00 fa[fa]fa fa fa fa fa fa fa fa fa
  0x0c067fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8080: 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
==108944==ABORTING

Desktop (please complete the following information):

  • ubuntu18
  • gcc 7.4.0
  • -fsanitize=address -g
@cuanduo cuanduo added the bug label Jul 12, 2019
@cuanduo cuanduo changed the title AddressSanitizer: heap-buffer-overflow in MemIo::read AddressSanitizer: heap-buffer-overflow in RafImage::readMetadata Jul 12, 2019
@piponazo piponazo added the notReproducible Reported bugs not confirmed label Jul 15, 2019
@piponazo
Copy link
Collaborator

As in #954, I could not reproduce the issue on master nor in 0.27-maintenance. I tried with gcc 7 and 8, and clang 6, using address sanitizer and release and debug modes ... am I missing something ?

@cuanduo
Copy link
Author

cuanduo commented Jul 16, 2019

As in #954, I could not reproduce the issue on master nor in 0.27-maintenance. I tried with gcc 7 and 8, and clang 6, using address sanitizer and release and debug modes ... am I missing something ?

in master
and version the day 7.12 i test
git checkout -b c4f8561

@piponazo
Copy link
Collaborator

I'm closing this after the findings in #953

@kirotawa
Copy link

It was assigned CVE-2019-14368 number for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug notReproducible Reported bugs not confirmed
Projects
None yet
Development

No branches or pull requests

3 participants