Menu

#56 Heap-buffer-overflow READ 2 (147065247)

v1.0 (example)
open
nobody
None
5
2020-03-20
2020-03-20
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_147065247.zip
docker build --build-arg SANITIZER=address --tag=autofuzz-InChI-147065247 autofuzz_147065247
docker run --entrypoint /fuzzing/repro.sh --cap-add=SYS_PTRACE -v $PWD/autofuzz_147065247/471c11dc-1e6c-453d-bafe-82c55974cd4e:/tmp/poc autofuzz-InChI-147065247 "" /tmp/poc
docker run --cap-add=SYS_PTRACE -v $PWD/autofuzz_147065247/471c11dc-1e6c-453d-bafe-82c55974cd4e:/tmp/poc -it autofuzz-InChI-147065247

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: 2934466787
/fuzzing/fuzzer: Running 1 inputs 1 time(s) each.
Running: /tmp/471c11dc-1e6c-453d-bafe-82c55974cd4e
=================================================================
==6==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61900000187c at pc 0x000000738e07 bp 0x7ffe63888e10 sp 0x7ffe63888e08
READ of size 2 at 0x61900000187c thread T0
    #0 0x738e06 in EvaluateChargeChanges /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr1.c:4338:32
    #1 0x739126 in RunBnsTestOnce /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr1.c:4479:16
    #2 0x7582ee in EliminateChargeSeparationOnHeteroatoms /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr2.c:3374:23
    #3 0x709193 in RunBnsRestore1 /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c:2413:11
    #4 0x70abb0 in RestoreAtomMakeBNS /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c:2776:11
    #5 0x70b3a6 in OneInChI2Atom /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c:2849:11
    #6 0x6a7d30 in InChI2Atom /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr7.c:161:11
    #7 0x6aa97f in AllInchiToStructure /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr7.c:887:23
    #8 0x6882ac in ConvertInChI2Struct /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:9072:11
    #9 0x67c3d3 in ReadWriteInChI /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:1055:23
    #10 0x5317f1 in GetStructFromINCHIEx /fuzzing/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c:2481:16
    #11 0x530c4e in GetStructFromINCHI /fuzzing/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c:2626:11
    #12 0x4fbd42 in LLVMFuzzerTestOneInput /fuzzing/security-research-pocs/autofuzz/inchi_fuzzer.cc:27:3
    #13 0x509fd3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/fuzzer+0x509fd3)
    #14 0x4fc603 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/fuzzing/fuzzer+0x4fc603)
    #15 0x500ae2 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/fuzzing/fuzzer+0x500ae2)
    #16 0x4fc31b in main (/fuzzing/fuzzer+0x4fc31b)
    #17 0x7f8b08b9309a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #18 0x421b19 in _start (/fuzzing/fuzzer+0x421b19)
0x61900000187c is located 60 bytes to the right of 960-byte region [0x619000001480,0x619000001840)
allocated by thread T0 here:
    #0 0x4c9b5a in calloc (/fuzzing/fuzzer+0x4c9b5a)
    #1 0x735240 in AllocateAndInitTCGBnStruct /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr1.c:3882:45
    #2 0x70aa64 in RestoreAtomMakeBNS /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c:2746:12
    #3 0x70b3a6 in OneInChI2Atom /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c:2849:11
    #4 0x6a7d30 in InChI2Atom /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr7.c:161:11
    #5 0x6aa97f in AllInchiToStructure /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr7.c:887:23
    #6 0x6882ac in ConvertInChI2Struct /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:9072:11
    #7 0x67c3d3 in ReadWriteInChI /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichiread.c:1055:23
    #8 0x5317f1 in GetStructFromINCHIEx /fuzzing/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c:2481:16
    #9 0x530c4e in GetStructFromINCHI /fuzzing/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c:2626:11
    #10 0x4fbd42 in LLVMFuzzerTestOneInput /fuzzing/security-research-pocs/autofuzz/inchi_fuzzer.cc:27:3
    #11 0x509fd3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/fuzzer+0x509fd3)
SUMMARY: AddressSanitizer: heap-buffer-overflow /fuzzing/INCHI-1-SRC/INCHI_BASE/src/ichirvr1.c:4338:32 in EvaluateChargeChanges
Shadow bytes around the buggy address:
  0x0c327fff82b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c327fff82c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c327fff82d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c327fff82e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c327fff82f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c327fff8300: 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa[fa]
  0x0c327fff8310: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c327fff8320: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c327fff8330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c327fff8340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c327fff8350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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