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_121468096.zip
docker build --build-arg SANITIZER=address --tag=autofuzz-InChI-121468096 autofuzz_121468096
docker run --entrypoint /fuzzing/repro.sh --cap-add=SYS_PTRACE -v $PWD/autofuzz_121468096/poc-c0ef70ef0b2b603b35a7bcb2495210a9c610d440a2e99a47293279f03214e849_min:/tmp/poc autofuzz-InChI-121468096 "" /tmp/poc
docker run --cap-add=SYS_PTRACE -v $PWD/autofuzz_121468096/poc-c0ef70ef0b2b603b35a7bcb2495210a9c610d440a2e99a47293279f03214e849_min:/tmp/poc -it autofuzz-InChI-121468096
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: 260088471
INFO: Loaded 0 modules (0 guards):
/fuzzing/fuzzer: Running 1 inputs 500 time(s) each.
Running: /tmp/poc-c0ef70ef0b2b603b35a7bcb2495210a9c610d440a2e99a47293279f03214e849
=================================================================
==6==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x604000000578 at pc 0x0000004c71ac bp 0x7ffe74ec5620 sp 0x7ffe74ec4dd0
READ of size 40 at 0x604000000578 thread T0
#0 0x4c71ab in __asan_memcpy (/fuzzing/fuzzer+0x4c71ab)
#1 0x6b2547 in make_a_copy_of_t_group_info /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichitaut.c:4032:17
#2 0x6032d0 in Create_INChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichimake.c:3039:13
#3 0x6fe754 in MakeOneInChIOutOfStrFromINChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr1.c:4411:14
#4 0x6ce8a7 in RestoreAtomMakeBNS /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr4.c:2633:15
#5 0x6cfd48 in OneInChI2Atom /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr4.c:2840:11
#6 0x67e7fc in InChI2Atom /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr7.c:131:11
#7 0x681407 in AllInchiToStructure /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr7.c:787:23
#8 0x659c40 in ReadWriteInChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichiread.c:929:23
#9 0x543f6e in GetStructFromINCHI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/inchi_dll.c:2293:16
#10 0x518759 in LLVMFuzzerTestOneInput /fuzzing/security-research-pocs/autofuzz/inchi_fuzzer.cc:27:3
#11 0x523ede in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/fuzzer+0x523ede)
#12 0x51903e in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/fuzzing/fuzzer+0x51903e)
#13 0x51d547 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/fuzzing/fuzzer+0x51d547)
#14 0x518d5b in main (/fuzzing/fuzzer+0x518d5b)
#15 0x7f0d71fad2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
#16 0x41ff89 in _start (/fuzzing/fuzzer+0x41ff89)
0x604000000578 is located 0 bytes to the right of 40-byte region [0x604000000550,0x604000000578)
allocated by thread T0 here:
#0 0x4de320 in calloc (/fuzzing/fuzzer+0x4de320)
#1 0x6ae0c5 in MarkTautomerGroups /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichitaut.c:3262:49
#2 0x591069 in mark_alt_bonds_and_taut_groups /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichi_bns.c:4533:48
#3 0x6028a9 in Create_INChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichimake.c:2960:15
#4 0x6fe754 in MakeOneInChIOutOfStrFromINChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr1.c:4411:14
#5 0x6ce8a7 in RestoreAtomMakeBNS /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr4.c:2633:15
#6 0x6cfd48 in OneInChI2Atom /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr4.c:2840:11
#7 0x67e7fc in InChI2Atom /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr7.c:131:11
#8 0x681407 in AllInchiToStructure /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichirvr7.c:787:23
#9 0x659c40 in ReadWriteInChI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/ichiread.c:929:23
#10 0x543f6e in GetStructFromINCHI /fuzzing/INCHI-1-API/INCHI_API/inchi_dll/inchi_dll.c:2293:16
#11 0x518759 in LLVMFuzzerTestOneInput /fuzzing/security-research-pocs/autofuzz/inchi_fuzzer.cc:27:3
#12 0x523ede in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/fuzzer+0x523ede)
SUMMARY: AddressSanitizer: heap-buffer-overflow (/fuzzing/fuzzer+0x4c71ab) in __asan_memcpy
Shadow bytes around the buggy address:
0x0c087fff8050: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
0x0c087fff8060: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
0x0c087fff8070: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
0x0c087fff8080: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
0x0c087fff8090: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
=>0x0c087fff80a0: fa fa fd fd fd fd fd fd fa fa 00 00 00 00 00[fa]
0x0c087fff80b0: fa fa 00 00 00 00 00 fa fa fa fa fa fa fa fa fa
0x0c087fff80c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c087fff80d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c087fff80e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c087fff80f0: 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
==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