comdb2 icon indicating copy to clipboard operation
comdb2 copied to clipboard

We found a heap-buffer-overflow error when fuzzing ASAN hardened comdb2

Open Ljiee opened this issue 6 years ago • 2 comments

command: ./comdb2 --dir db testdb

=================================================================
==2104658==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6040000001c0 at pc 0x563a00fabdc4 bp 0x7ffec6eadde0 sp 0x7ffec6eaddd8
READ of size 8 at 0x6040000001c0 thread T0
    #0 0x563a00fabdc3 in comdb2_free /root/workspace/comdb2/sources/mem/mem.c:999:14
    #1 0x5639ff820894 in set_dbdir /root/workspace/comdb2/sources/db/config.c:146:5
    #2 0x5639ff820894 in handle_cmdline_options /root/workspace/comdb2/sources/db/config.c:236:28
    #3 0x5639ff7c1f8f in init /root/workspace/comdb2/sources/db/comdb2.c:3432:5
    #4 0x5639ff7bfe95 in main /root/workspace/comdb2/sources/db/comdb2.c:5466:9
    #5 0x7f50c047c001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
    #6 0x5639ff6987cd in _start (/root/workspace/comdb2/bin_asan/comdb2+0x6eb7cd)

0x6040000001c0 is located 16 bytes to the left of 41-byte region [0x6040000001d0,0x6040000001f9)
allocated by thread T0 here:
    #0 0x5639ff73c052 in realloc (/root/workspace/comdb2/bin_asan/comdb2+0x78f052)
    #1 0x7f50c0546abf in getcwd (/usr/lib/libc.so.6+0xf1abf)

SUMMARY: AddressSanitizer: heap-buffer-overflow /root/workspace/comdb2/sources/mem/mem.c:999:14 in comdb2_free
Shadow bytes around the buggy address:
  0x0c087fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c087fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c087fff8000: fa fa fd fd fd fd fd fd fa fa 00 00 00 00 00 03
  0x0c087fff8010: fa fa 00 00 00 00 00 00 fa fa fd fd fd fd fd fa
  0x0c087fff8020: fa fa fd fd fd fd fd fa fa fa fd fd fd fd fd fa
=>0x0c087fff8030: fa fa fd fd fd fd fd fa[fa]fa 00 00 00 00 00 01
  0x0c087fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fff8080: 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
==2104658==ABORTING

Ljiee avatar May 17 '20 11:05 Ljiee

Commit 79ed3be should fix.

akshatsikarwar avatar Jun 18 '20 16:06 akshatsikarwar

Thank you for the bug report.

akshatsikarwar avatar Jun 18 '20 16:06 akshatsikarwar