Menu

#69 Heap-buffer-overflow in ParseSegmentMobileH

v1.0 (example)
open
nobody
None
5
2020-05-12
2020-05-12
No

Hello InChI team,

As part of our fuzzing efforts at Google, we have identified an issue affecting
InChI (tested with revision v1.05, January 2017).

To reproduce, we are attaching a Dockerfile which compiles the project with
LLVM, taking advantage of the sanitizers that it offers. More information about
how to use the attached Dockerfile can be found here:
https://docs.docker.com/engine/reference/builder/

Instructions:

  • unzip artifacts_146684438.zip
  • docker build --build-arg SANITIZER=address --tag=autofuzz-InChI-146684438 autofuzz_146684438
  • docker run --entrypoint /fuzzing/repro.sh --cap-add=SYS_PTRACE -v $PWD/autofuzz_146684438/7bd02a39-c10f-4d79-8ef9-e506cfeddd98:/tmp/poc autofuzz-InChI-146684438 "" /tmp/poc
  • docker run --cap-add=SYS_PTRACE -v $PWD/autofuzz_146684438/7bd02a39-c10f-4d79-8ef9-e506cfeddd98:/tmp/poc -it autofuzz-InChI-146684438

Alternatively, and depending on the bug, you could use gcc, valgrind or other
instrumentation tools to aid in the investigation. The sanitizer error that we
encountered is here:

running fuzzer...
INFO: Seed: 170047229
/fuzzing/fuzzer: Running 1 inputs 1 time(s) each.
Running: /tmp/7bd02a39-c10f-4d79-8ef9-e506cfeddd98
=================================================================
==6==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000192 at pc 0x0000004c8a16 bp 0x7ffcafca5ab0 sp 0x7ffcafca5260
READ of size 8 at 0x602000000192 thread T0
    #0 0x4c8a15 in __asan_memcpy (/fuzzing/fuzzer+0x4c8a15)
    #1 0x69a58e in ParseSegmentMobileH /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:6733:13
    #2 0x68b91f in ReadInChILine /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:4554:19
    #3 0x67e8b6 in InChILine2Data /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:2206:11
    #4 0x67bb7a in ReadWriteInChI /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:794:23
    #5 0x5299a9 in GetINCHIfromINCHI /fuzzing/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c:2119:16
    #6 0x4fbd21 in LLVMFuzzerTestOneInput /fuzzing/security-research-pocs/autofuzz/inchi_fuzzer.cc:23:3
    #7 0x509fd3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/fuzzer+0x509fd3)
    #8 0x4fc603 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/fuzzing/fuzzer+0x4fc603)
    #9 0x500ae2 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/fuzzing/fuzzer+0x500ae2)
    #10 0x4fc31b in main (/fuzzing/fuzzer+0x4fc31b)
    #11 0x7f5b68c9509a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #12 0x421b19 in _start (/fuzzing/fuzzer+0x421b19)
0x602000000192 is located 0 bytes to the right of 2-byte region [0x602000000190,0x602000000192)
allocated by thread T0 here:
    #0 0x4c9b5a in calloc (/fuzzing/fuzzer+0x4c9b5a)
    #1 0x69a4ff in ParseSegmentMobileH /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:6727:45
    #2 0x68bf25 in ReadInChILine /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:4428:19
    #3 0x67e8b6 in InChILine2Data /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:2206:11
    #4 0x67bb7a in ReadWriteInChI /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:794:23
    #5 0x5299a9 in GetINCHIfromINCHI /fuzzing/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c:2119:16
    #6 0x4fbd21 in LLVMFuzzerTestOneInput /fuzzing/security-research-pocs/autofuzz/inchi_fuzzer.cc:23:3
    #7 0x509fd3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/fuzzer+0x509fd3)
SUMMARY: AddressSanitizer: heap-buffer-overflow (/fuzzing/fuzzer+0x4c8a15) in __asan_memcpy
Shadow bytes around the buggy address:
  0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff8000: fa fa 01 fa fa fa 00 07 fa fa 00 07 fa fa 00 00
  0x0c047fff8010: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fff8020: fa fa fd fd fa fa 02 fa fa fa 02 fa fa fa 04 fa
=>0x0c047fff8030: fa fa[02]fa fa fa 03 fa fa fa 00 01 fa fa 00 01
  0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8080: 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
==6==ABORTING

We will gladly work with you so you can successfully confirm and reproduce this
issue. Do let us know if you have any feedback surrounding the documentation.

Once you have reproduced the issue, we'd appreciate to learn your expected
timeline for an update to be released. With any fix, please attribute the report
to "Google Autofuzz project".

We are also pleased to inform you that your project is eligible for inclusion to
the OSS-Fuzz project, which can provide additional continuous fuzzing, and
encourage you to investigate integration options.

Don't hesitate to let us know if you have any questions!

Google AutoFuzz Team

1 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB