Bug 1524107

Summary: exiv2 library: heap-based buffer over-read in Exiv2::IptcData::printStructure (iptc.cpp)
Product: Red Hat Enterprise Linux 7 Reporter: Wei You <WeiYou1988>
Component: exiv2Assignee: Jan Grulich <jgrulich>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 7.5-Alt   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-06 12:47:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
poc to trigger the vulnerability none

Description Wei You 2017-12-10 06:21:33 UTC
Created attachment 1365483 [details]
poc to trigger the vulnerability

on 0.26 (the latest version):

there is a heap-based buffer over-read in the Exiv2::IptcData::printStructure function (src/iptc.cpp), which can be triggered by poc_1.tiff in the
attachment.

Note that this vulnerability exists in the exiv2 library, any software using
exiv2 will be affected by this vulnerability. Remote attackers can exploit
this vulnerability to cause a denial of service via a crafted tiff file.

As a demonstration, please run the following command-line to trigger this
vulnerability:


./0.26/bin/exiv2 poc_1.tiff 
=================================================================
==12019==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000ed71 at pc 0x00000063908e bp 0x7ffe694d4400 sp 0x7ffe694d43f0
READ of size 1 at 0x60200000ed71 thread T0
    #0 0x63908d in Exiv2::IptcData::printStructure(std::ostream&, unsigned char const*, unsigned long, unsigned int) /home/fuzz/exiv2/0.26/src/iptc.cpp:359
    #1 0x61d9d2 in Exiv2::Image::printIFDStructure(Exiv2::BasicIo&, std::ostream&, Exiv2::PrintStructureOption, unsigned int, bool, char, int) /home/fuzz/exiv2/0.26/src/image.cpp:454
    #2 0x622035 in Exiv2::Image::printTiffStructure(Exiv2::BasicIo&, std::ostream&, Exiv2::PrintStructureOption, int, unsigned long) /home/fuzz/exiv2/0.26/src/image.cpp:517
    #3 0x7ea794 in Exiv2::TiffImage::printStructure(std::ostream&, Exiv2::PrintStructureOption, int) /home/fuzz/exiv2/0.26/src/tiffimage.cpp:348
    #4 0x7fa25d in Exiv2::TiffImage::readMetadata() /home/fuzz/exiv2/0.26/src/tiffimage.cpp:191
    #5 0x4f2ea6 in Action::Print::printSummary() /home/fuzz/exiv2/0.26/src/actions.cpp:289
    #6 0x4f7907 in Action::Print::run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/fuzz/exiv2/0.26/src/actions.cpp:244
    #7 0x409cec in main /home/fuzz/exiv2/0.26/src/exiv2.cpp:170
    #8 0x7fc10c3c082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #9 0x48f718 in _start (/home/fuzz/exiv2/0.26/bin/exiv2+0x48f718)

0x60200000ed71 is located 0 bytes to the right of 1-byte region [0x60200000ed70,0x60200000ed71)
allocated by thread T0 here:
    #0 0x7fc10d7046b2 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x996b2)
    #1 0x61d873 in Exiv2::Image::printIFDStructure(Exiv2::BasicIo&, std::ostream&, Exiv2::PrintStructureOption, unsigned int, bool, char, int) /home/fuzz/exiv2/0.26/src/image.cpp:451
    #2 0x622035 in Exiv2::Image::printTiffStructure(Exiv2::BasicIo&, std::ostream&, Exiv2::PrintStructureOption, int, unsigned long) /home/fuzz/exiv2/0.26/src/image.cpp:517
    #3 0x7ea794 in Exiv2::TiffImage::printStructure(std::ostream&, Exiv2::PrintStructureOption, int) /home/fuzz/exiv2/0.26/src/tiffimage.cpp:348

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/fuzz/exiv2/0.26/src/iptc.cpp:359 Exiv2::IptcData::printStructure(std::ostream&, unsigned char const*, unsigned long, unsigned int)
Shadow bytes around the buggy address:
  0x0c047fff9d50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9d60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9d70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9d80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  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[01]fa
  0x0c047fff9db0: fa fa 00 fa fa fa 00 fa fa fa 00 fa fa fa fd fd
  0x0c047fff9dc0: fa fa 06 fa fa fa 00 04 fa fa 00 04 fa fa 00 04
  0x0c047fff9dd0: fa fa 00 04 fa fa 00 04 fa fa 00 04 fa fa 00 04
  0x0c047fff9de0: fa fa 00 04 fa fa 00 04 fa fa 00 04 fa fa 00 04
  0x0c047fff9df0: fa fa 00 04 fa fa 00 04 fa fa 00 04 fa fa fd 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
==12019==ABORTING

Comment 4 Jan Grulich 2019-01-28 16:08:25 UTC
Fixed with exiv2-0.27.0-1.el7_6.

Comment 8 errata-xmlrpc 2019-08-06 12:47:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:2101