Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heap buffer overflow in mjs_mk_string() at mjs.c:13671 #244

Open
fengzhengzhan opened this issue Mar 22, 2023 · 0 comments
Open

Heap buffer overflow in mjs_mk_string() at mjs.c:13671 #244

fengzhengzhan opened this issue Mar 22, 2023 · 0 comments

Comments

@fengzhengzhan
Copy link

Heap buffer overflow in mjs at function mjs_mk_string in mjs.c:13671.

Environment

Ubuntu 18.04, 64 bit

Steps to reproduce

  1. download file
git clone https://github.com/cesanta/mjs.git mjs
cd mjs
git checkout 9eae0e6
  1. compile libming with ASAN
clang -fsanitize=address mjs.c -o mjs_asan
  1. command for reproducing the error
./mjs_asan -f poc

Download poc:
mjs_heap-buffer-overflow_mjs13671.zip

ASAN report

> ./mjs_asan -f mjs_heap-buffer-overflow_mjs13671
=================================================================
==23460==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60800000007d at pc 0x00000046b929 bp 0x7fff87d05cd0 sp 0x7fff87d05480
READ of size 94 at 0x60800000007d thread T0
    #0 0x46b928 in __interceptor_strlen.part.0 /home/fzz/Desktop/STFGFuzz/LLVM/llvm/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:372:5
    #1 0x510fbf in mjs_mk_string /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:13671:35
    #2 0x5328d2 in frozen_cb /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:11870:13
    #3 0x5162ac in parse_string /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:5884:9
    #4 0x51597c in parse_value /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:5970:7
    #5 0x516bb3 in parse_array /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:5936:9
    #6 0x515a94 in parse_value /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:5976:7
    #7 0x503145 in doit /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:6058:10
    #8 0x50077b in json_walk /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:6434:3
    #9 0x532618 in mjs_json_parse /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:11963:14
    #10 0x50a501 in mjs_op_json_parse /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:12012:5
    #11 0x50e248 in mjs_execute /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:9541:11
    #12 0x50c4ce in mjs_exec_internal /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:9758:5
    #13 0x50c610 in mjs_exec_file /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:9781:11
    #14 0x50fe4f in main /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:12051:13
    #15 0x7f5460494082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #16 0x41c3cd in _start (/home/fzz/Desktop/STFGFuzz/Programs/mjs-issues-78/seeds_crash/mjs_asan+0x41c3cd)

0x60800000007d is located 0 bytes to the right of 93-byte region [0x608000000020,0x60800000007d)
allocated by thread T0 here:
    #0 0x4c1f3f in malloc /home/fzz/Desktop/STFGFuzz/LLVM/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0x53287b in frozen_cb /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:11868:36
    #2 0x5162ac in parse_string /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:5884:9
    #3 0x51597c in parse_value /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:5970:7
    #4 0x516bb3 in parse_array /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:5936:9
    #5 0x515a94 in parse_value /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:5976:7
    #6 0x503145 in doit /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:6058:10
    #7 0x50077b in json_walk /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:6434:3
    #8 0x532618 in mjs_json_parse /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:11963:14
    #9 0x50a501 in mjs_op_json_parse /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:12012:5
    #10 0x50e248 in mjs_execute /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:9541:11
    #11 0x50c4ce in mjs_exec_internal /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:9758:5
    #12 0x50c610 in mjs_exec_file /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:9781:11
    #13 0x50fe4f in main /root/compiler1804/aflgo_dataset/mjs-issues-78/mjs.c:12051:13
    #14 0x7f5460494082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/fzz/Desktop/STFGFuzz/LLVM/llvm/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:372:5 in __interceptor_strlen.part.0
Shadow bytes around the buggy address:
  0x0c107fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c107fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c107fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c107fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c107fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c107fff8000: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00[05]
  0x0c107fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c107fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c107fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c107fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c107fff8050: 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
==23460==ABORTING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant