Menu

#31 Stack Out-Of-Bounds Memory Access (121413377)

v1.0 (example)
open
nobody
None
5
2018-12-26
2018-12-26
No

Hello InChI team,

As part of our fuzzing efforts at Google, we have identified an issue affecting
InChI (tested with revision v1.04, September 2011).

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_121413377.zip
docker build --build-arg SANITIZER=address --tag=autofuzz-InChI-121413377 autofuzz_121413377
docker run --entrypoint /fuzzing/repro.sh --cap-add=SYS_PTRACE -v $PWD/autofuzz_121413377/poc-6bd0ac18d516ecb2480bca989d6c2571822a34266ee4a9eb366466d9bf540837_min:/tmp/poc autofuzz-InChI-121413377 "" /tmp/poc
docker run --cap-add=SYS_PTRACE -v $PWD/autofuzz_121413377/poc-6bd0ac18d516ecb2480bca989d6c2571822a34266ee4a9eb366466d9bf540837_min:/tmp/poc -it autofuzz-InChI-121413377

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:

INFO: Seed: 3387662671
INFO: Loaded 0 modules (0 guards): 
/fuzzing/fuzzer: Running 1 inputs 500 time(s) each.
Running: /tmp/poc-6bd0ac18d516ecb2480bca989d6c2571822a34266ee4a9eb366466d9bf540837
=================================================================
==6==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffe253334ca at pc 0x000000591a06 bp 0x7ffe25332fd0 sp 0x7ffe25332fc8
READ of size 2 at 0x7ffe253334ca thread T0
    #0 0x591a05 in mark_alt_bonds_and_taut_groups /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichi_bns.c:4787:80
    #1 0x6028a9 in Create_INChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichimake.c:2960:15
    #2 0x6fe754 in MakeOneInChIOutOfStrFromINChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr1.c:4411:14
    #3 0x6ce8a7 in RestoreAtomMakeBNS /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr4.c:2633:15
    #4 0x6cfd48 in OneInChI2Atom /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr4.c:2840:11
    #5 0x67e7fc in InChI2Atom /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr7.c:131:11
    #6 0x681407 in AllInchiToStructure /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr7.c:787:23
    #7 0x659c40 in ReadWriteInChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichiread.c:929:23
    #8 0x543f6e in GetStructFromINCHI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/inchi_dll.c:2293:16
    #9 0x518759 in LLVMFuzzerTestOneInput /fuzzing/security-research-pocs/autofuzz/inchi_fuzzer.cc:27:3
    #10 0x523ede in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/fuzzer+0x523ede)
    #11 0x51903e in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/fuzzing/fuzzer+0x51903e)
    #12 0x51d547 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/fuzzing/fuzzer+0x51d547)
    #13 0x518d5b in main (/fuzzing/fuzzer+0x518d5b)
    #14 0x7f0765be82e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #15 0x41ff89 in _start (/fuzzing/fuzzer+0x41ff89)

Address 0x7ffe253334ca is located in stack of thread T0 at offset 330 in frame
    #0 0x601ecf in Create_INChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichimake.c:2805

  This frame has 9 object(s):
    [32, 48) 'at' (line 2810)
    [64, 168) 'vt_group_info' (line 2814)
    [208, 312) 'vt_group_info_orig' (line 2815) <== Memory access at offset 330 overflows this variable
    [352, 880) 'CS' (line 2819)
    [1008, 1536) 'CS2' (line 2819)
    [1664, 1784) 's' (line 2823)
    [1824, 2224) 'Bcn' (line 2825)
    [2288, 2296) 'bTautFlags' (line 2839)
    [2320, 2328) 'bTautFlagsDone' (line 2840)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichi_bns.c:4787:80 in mark_alt_bonds_and_taut_groups
Shadow bytes around the buggy address:
  0x100044a5e640: 00 00 00 00 f3 f3 f3 f3 00 00 00 00 00 00 00 00
  0x100044a5e650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100044a5e660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100044a5e670: f1 f1 f1 f1 00 00 f2 f2 00 00 00 00 00 00 00 00
  0x100044a5e680: 00 00 00 00 00 f2 f2 f2 f2 f2 00 00 00 00 00 00
=>0x100044a5e690: 00 00 00 00 00 00 00 f2 f2[f2]f2 f2 00 00 00 00
  0x100044a5e6a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100044a5e6b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100044a5e6c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100044a5e6d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f2 f2
  0x100044a5e6e0: f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 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
==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