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 at jsi_utf_tocase src/jsiString.c:396 #32

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

heap-buffer-overflow at jsi_utf_tocase src/jsiString.c:396 #32

kvenux opened this issue Oct 31, 2020 · 1 comment

Comments

@kvenux
Copy link

kvenux commented Oct 31, 2020

Build environment:

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

POC

jsish-1024-000124.txt

Description

Below is the ASAN outputs.

=================================================================
==2511==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60d00000ce56 at pc 0x0000004e8763 bp 0x7fff6dd3ff40 sp 0x7fff6dd3ff30
READ of size 1 at 0x60d00000ce56 thread T0
#0 0x4e8762 in jsi_utf_tocase src/jsiString.c:396
#1 0x4e951f in StringToLowerCaseCmd src/jsiString.c:432
#2 0x4c405d in jsi_FuncCallSub src/jsiProto.c:244
#3 0x73eaa4 in jsiFunctionSubCall src/jsiEval.c:790
#4 0x73eaa4 in jsiEvalFunction src/jsiEval.c:825
#5 0x73eaa4 in jsiEvalCodeSub src/jsiEval.c:1250
#6 0x7506ec in jsi_evalcode src/jsiEval.c:2190
#7 0x4c517a in jsi_FuncCallSub src/jsiProto.c:220
#8 0x73e7ca in jsiFunctionSubCall src/jsiEval.c:790
#9 0x73e7ca in jsiEvalFunction src/jsiEval.c:825
#10 0x73e7ca in jsiEvalCodeSub src/jsiEval.c:1250
#11 0x7506ec in jsi_evalcode src/jsiEval.c:2190
#12 0x4c517a in jsi_FuncCallSub src/jsiProto.c:220
#13 0x73e7ca in jsiFunctionSubCall src/jsiEval.c:790
#14 0x73e7ca in jsiEvalFunction src/jsiEval.c:825
#15 0x73e7ca in jsiEvalCodeSub src/jsiEval.c:1250
#16 0x7506ec in jsi_evalcode src/jsiEval.c:2190
#17 0x75317f in jsi_evalStrFile src/jsiEval.c:2496
#18 0x499c46 in Jsi_Main src/jsiInterp.c:917
#19 0xc0345a in jsi_main src/main.c:44
#20 0x7f78c529883f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
#21 0x434f48 in _start (/home/keven/Fuzzing/jsish-1024/jsish+0x434f48)

0x60d00000ce56 is located 0 bytes to the right of 134-byte region [0x60d00000cdd0,0x60d00000ce56)
allocated by thread T0 here:
#0 0x7f78c5e04602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
#1 0x49e422 in Jsi_Malloc src/jsiUtils.c:52

SUMMARY: AddressSanitizer: heap-buffer-overflow src/jsiString.c:396 jsi_utf_tocase
Shadow bytes around the buggy address:
0x0c1a7fff9970: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c1a7fff9980: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c1a7fff9990: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c1a7fff99a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c1a7fff99b0: fa fa fa fa fa fa fa fa fa fa 00 00 00 00 00 00
=>0x0c1a7fff99c0: 00 00 00 00 00 00 00 00 00 00[06]fa fa fa fa fa
0x0c1a7fff99d0: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
0x0c1a7fff99e0: 00 00 00 00 00 00 fa fa fa fa fa fa fa fa 00 00
0x0c1a7fff99f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 fa
0x0c1a7fff9a00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c1a7fff9a10: 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
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
==2511==ABORTING

@pcmacdon
Copy link
Owner

The index was mistakenly a char, which wrapped at 128. Terrific find.

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