Project: exiv2 (exiv2/exiv2), language: c++
Vulnerability instance: exiv2.cve-2018-14046
Sanitizer: address

================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/Exiv2/exiv2/issues/378
## Description:
Issue: Exiv2/exiv2#378
Title: AddressSanitizer: heap-buffer-overflow /src/exiv2/src/webpimage.cpp:563 Exiv2::WebPImage::decodeChunks(unsigned long)
State: closed
Created by: cool-tomato
Created at: 2018-07-09 01:52:51+00:00

Issue Body:
```
$ exiv2 -pp $POC 

=================================================================
==23==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000ef32 at pc 0x7f19a962fc0e bp 0x7fff01cdcc00 sp 0x7fff01cdcbf0
READ of size 3 at 0x60200000ef32 thread T0
    #0 0x7f19a962fc0d in Exiv2::WebPImage::decodeChunks(unsigned long) /src/exiv2/src/webpimage.cpp:563
    #1 0x7f19a9634cbe in Exiv2::WebPImage::readMetadata() /src/exiv2/src/webpimage.cpp:496
    #2 0x462b13 in Action::Print::printPreviewList() /src/exiv2/src/actions.cpp:801
    #3 0x46f837 in Action::Print::run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /src/exiv2/src/actions.cpp:254
    #4 0x40c735 in main /src/exiv2/src/exiv2.cpp:166
    #5 0x7f19a87b482f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #6 0x40d688 in _start (/src/aflbuild/installed/bin/exiv2+0x40d688)

0x60200000ef34 is located 0 bytes to the right of 4-byte region [0x60200000ef30,0x60200000ef34)
allocated by thread T0 here:
    #0 0x7f19a9f656b2 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x996b2)
    #1 0x7f19a962bbc7 in Exiv2::DataBuf::DataBuf(long) /src/exiv2/include/exiv2/types.hpp:206
    #2 0x7f19a962bbc7 in Exiv2::WebPImage::decodeChunks(unsigned long) /src/exiv2/src/webpimage.cpp:517

SUMMARY: AddressSanitizer: heap-buffer-overflow /src/exiv2/src/webpimage.cpp:563 Exiv2::WebPImage::decodeChunks(unsigned long)
Shadow bytes around the buggy address:
  0x0c047fff9d90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9da0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9db0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9dc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9dd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c047fff9de0: fa fa fa fa fa fa[04]fa fa fa 05 fa fa fa 05 fa
  0x0c047fff9df0: fa fa 00 fa fa fa 00 fa fa fa 00 fa fa fa fd fa
  0x0c047fff9e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9e30: 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
==23==ABORTING
```
[1-poc-heapoverflow](https://github.com/TeamSeri0us/pocs/blob/master/exiv2/1-poc-heapoverflow)




Comments:
Comment by kirotawa on 2018-07-16 14:20:50+00:00:
It was assigned this CVE number for this issue  https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-14046

Build script:
#!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
mkdir -p build
cd build
cmake -DEXIV2_ENABLE_PNG=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_CURL=OFF -DEXIV2_ENABLE_BMFF=ON -DEXIV2_TEAM_WARNINGS_AS_ERRORS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_CXX_FLAGS="${CXXFLAGS}" -DEXIV2_BUILD_FUZZ_TESTS=ON -DEXIV2_TEAM_OSS_FUZZ=ON -DLIB_FUZZING_ENGINE="${LIB_FUZZING_ENGINE}" ..
make -j $(nproc)

Dockerfile:
FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y cmake make ccache python3 libexpat1-dev zlib1g-dev libssh-dev libcurl4-openssl-dev libxml2-utils
RUN git clone https://github.com/exiv2/exiv2 exiv2
RUN git -C exiv2 checkout fa449a4d2c58d63f0d75ff259f25683a98a44630
WORKDIR $SRC/exiv2
COPY build.sh $SRC/

Additional files: