dmg2img icon indicating copy to clipboard operation
dmg2img copied to clipboard

A Segmentation fault in dmg2img.h:188

Open seviezhou opened this issue 4 years ago • 1 comments

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), dmg2img (latest master f16f24)

Command line

./dmg2img -i @@ -o /dev/null

Output

Segmentation fault

AddressSanitizer output

=================================================================
==39429==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x610000007ff9 at pc 0x7f58afaed935 bp 0x7ffcfd253e50 sp 0x7ffcfd2535f8
READ of size 204 at 0x610000007ff9 thread T0
    #0 0x7f58afaed934 in __asan_memcpy (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x8c934)
    #1 0x40b47e in memcpy /usr/include/x86_64-linux-gnu/bits/string3.h:53
    #2 0x40b47e in fill_mishblk /home/seviezhou/dmg2img/dmg2img.h:188
    #3 0x403332 in main /home/seviezhou/dmg2img/dmg2img.c:274
    #4 0x7f58af28d83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #5 0x408108 in _start (/home/seviezhou/dmg2img/dmg2img+0x408108)

0x610000007ff9 is located 0 bytes to the right of 185-byte region [0x610000007f40,0x610000007ff9)
allocated by thread T0 here:
    #0 0x7f58afaf9602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x40322d in main /home/seviezhou/dmg2img/dmg2img.c:265

SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 __asan_memcpy
Shadow bytes around the buggy address:
  0x0c207fff8fa0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c207fff8fb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c207fff8fc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c207fff8fd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c207fff8fe0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
=>0x0c207fff8ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00[01]
  0x0c207fff9000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c207fff9010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c207fff9020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c207fff9030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c207fff9040: 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
==39429==ABORTING

POC

heap-overflow-dmg2img-188.zip

seviezhou avatar Aug 02 '20 13:08 seviezhou

His appears to have CVE-2021-32614 assigned, cf. https://bugzilla.redhat.com/show_bug.cgi?id=1959911

carnil avatar May 14 '21 04:05 carnil