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-use-after-free at jsi_ArrayReduceSubCmd src/jsiArray.c:620 #25

Closed
kvenux opened this issue Oct 22, 2020 · 1 comment
Closed

heap-use-after-free at jsi_ArrayReduceSubCmd src/jsiArray.c:620 #25

kvenux opened this issue Oct 22, 2020 · 1 comment

Comments

@kvenux
Copy link

kvenux commented Oct 22, 2020

Build environment:

Ubuntu 16.04
gcc 5.4.0
version: 17c32ef
build command:
export JSI__SANITIZE=1
make
test command: ./jsish poc

POC

jsish-1021-000002.txt

Description

Below is the ASAN outputs.

=================================================================
==75149==ERROR: AddressSanitizer: heap-use-after-free on address 0x608000014048 at pc 0x0000004ff1ab bp 0x7ffc17dbe420 sp 0x7ffc17dbe410
READ of size 8 at 0x608000014048 thread T0
#0 0x4ff1aa in jsi_ArrayReduceSubCmd src/jsiArray.c:620
#1 0x4ff1aa in jsi_ArrayReduceRightCmd src/jsiArray.c:662
#2 0x4c4f20 in jsi_FuncCallSub src/jsiProto.c:244
#3 0x73e470 in jsiFunctionSubCall src/jsiEval.c:793
#4 0x73e470 in jsiEvalFunction src/jsiEval.c:828
#5 0x73e470 in jsiEvalCodeSub src/jsiEval.c:1253
#6 0x7509a7 in jsi_evalcode src/jsiEval.c:2188
#7 0x7534fb in jsi_evalStrFile src/jsiEval.c:2494
#8 0x49ae7e in Jsi_Main src/jsiInterp.c:917
#9 0xc07b32 in jsi_main src/main.c:44
#10 0x7f9608aca83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
#11 0x434fc8 in _start (/home/keven/Fuzzing/jsish-1021/jsish+0x434fc8)

0x608000014048 is located 40 bytes inside of 96-byte region [0x608000014020,0x608000014080)
freed by thread T0 here:
#0 0x7f96096362ca in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x982ca)
#1 0x57a5b7 in Jsi_ObjDecrRefCount src/jsiObj.c:434

previously allocated by thread T0 here:
#0 0x7f960963679a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
#1 0x49f5a4 in Jsi_Calloc src/jsiUtils.c:57

SUMMARY: AddressSanitizer: heap-use-after-free src/jsiArray.c:620 jsi_ArrayReduceSubCmd
Shadow bytes around the buggy address:
0x0c107fffa7b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c107fffa7c0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
0x0c107fffa7d0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x0c107fffa7e0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x0c107fffa7f0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c107fffa800: fa fa fa fa fd fd fd fd fd[fd]fd fd fd fd fd fd
0x0c107fffa810: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
0x0c107fffa820: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
0x0c107fffa830: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
0x0c107fffa840: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
0x0c107fffa850: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
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
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
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
==75149==ABORTING

pcmacdon pushed a commit that referenced this issue Oct 22, 2020
FossilOrigin-Name: 10777e7a64996c61fceb96e383fbdc35637693331d24576b1da5af8f188f8cdf
@pcmacdon
Copy link
Owner

Well, I'm glad you found this bug. It made me realise that the other Array callbacks passing this also suffer the same defect. I've changed them all to pass a copy instead.

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

2 participants