elfmaster / libelfmaster

Secure ELF parsing/loading library for forensics reconstruction of malware, and robust reverse engineering tools
http://www.bitlackeys.org
410 stars 64 forks source link

SEGV in resolve_plt_addr at internal.c:1340 #21

Open bladchan opened 2 years ago

bladchan commented 2 years ago

Describe the bug A bad elf file which can lead elf_open_object() to a segmentation fault. Poc here: poc3.zip

To Reproduce

  1. Build the whole project with ASAN
  2. Run examples/elfparse
    $ ./elfparse ./segv2

Expected behavior Parse elf file without segmentation fault because segmentation fault can cause a Denial of Service (Dos).

Environment (please complete the following information):

Additional context ASAN says:

ASAN:DEADLYSIGNAL
=================================================================
==37981==ERROR: AddressSanitizer: SEGV on unknown address 0x7f9e2fbfa000 (pc 0x558fe2223c2c bp 0x7ffd4012e440 sp 0x7ffd4012e420 T0)
==37981==The signal is caused by a READ memory access.
    #0 0x558fe2223c2b in resolve_plt_addr /home/ubuntu/some_c_test/libelfmaster/src/internal.c:1340
    #1 0x558fe22287d6 in reconstruct_elf_sections /home/ubuntu/some_c_test/libelfmaster/src/internal.c:1917
    #2 0x558fe221097a in elf_open_object /home/ubuntu/some_c_test/libelfmaster/src/libelfmaster.c:3237
    #3 0x558fe21ecb04 in main /home/ubuntu/some_c_test/libelfmaster/examples/elfparse.c:38
    #4 0x7f3e27be4c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
    #5 0x558fe21eec19 in _start (/home/ubuntu/some_c_test/libelfmaster/fuzz/elfparse+0x8c19)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/ubuntu/some_c_test/libelfmaster/src/internal.c:1340 in resolve_plt_addr
==37981==ABORTING