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 function mjs_execute (at mjs.c:8531) #300

Open
Vancir opened this issue Nov 19, 2024 · 0 comments
Open

heap-buffer-overflow in function mjs_execute (at mjs.c:8531) #300

Vancir opened this issue Nov 19, 2024 · 0 comments

Comments

@Vancir
Copy link

Vancir commented Nov 19, 2024

I found a heap buffer overflow while mjs (latest, b1b6eac) executes the PoC on Ubuntu 20.04.

Download the PoC: mjs_heap-buffer-overflow_mjs8531.zip

ASAN Report

==346708==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6040000000c0 at pc 0x0000004e0bee bp 0x7fff3f6c0410 sp 0x7fff3f6c0408                 
READ of size 8 at 0x6040000000c0 thread T0                                                                                                                 
    #0 0x4e0bed in mjs_execute /data/song/projects/latest-programs/mjs/BUILD/mjs.c:8531:38                                                                 
    #1 0xc2a00000013  (<unknown module>)                                                       
                                                                                                                                                           
0x6040000000c0 is located 0 bytes to the right of 48-byte region [0x604000000090,0x6040000000c0)                                                                                               
allocated by thread T0 here:                                                 
    #0 0x49a529 in realloc (/data/song/projects/latest-programs/mjs/mjs-bin+0x49a529)                                                                                                          
    #1 0x4cc463 in mbuf_insert /data/song/projects/latest-programs/mjs/BUILD/mjs.c:4095:18                                                                                                     
    #2 0x4cc686 in mbuf_append /data/song/projects/latest-programs/mjs/BUILD/mjs.c:4118:10                                                                                                     
    #3 0x4dc92c in push_mjs_val /data/song/projects/latest-programs/mjs/BUILD/mjs.c:7868:3                                                                                                     
    #4 0x4de4d5 in call_stack_push_frame /data/song/projects/latest-programs/mjs/BUILD/mjs.c:8015:3                                                                                            
    #5 0x4e077c in mjs_execute /data/song/projects/latest-programs/mjs/BUILD/mjs.c:8821:11                                                                                                     
    #6 0x4dd8ee in mjs_exec_internal /data/song/projects/latest-programs/mjs/BUILD/mjs.c:9044:5                                                                                                
    #7 0x4ddaeb in mjs_exec_file /data/song/projects/latest-programs/mjs/BUILD/mjs.c:9067:11                                                                                                   
    #8 0x4e1df7 in main /data/song/projects/latest-programs/mjs/BUILD/mjs.c:11406:13                                                                                                           
    #9 0x7f5f76dfcd8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16          

Steps to reproduce

git clone https://github.com/cesanta/mjs.git
cd mjs
clang -g -O1 -fsanitize=address -fno-omit-frame-pointer -Wno-error -DMJS_MAIN mjs.c -dl -o mjs_asan
./mjs_asan -f PoC 
@Vancir Vancir changed the title heap-buffer-overflow in function mjs_execute (at mjs.c:8531) of latest version (b1b6eac) heap-buffer-overflow in function mjs_execute (at mjs.c:8531) Nov 19, 2024
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