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 src/jsiEval.c:1726 in jsiEvalCodeSub #58

Closed
hope-fly opened this issue Dec 24, 2021 · 2 comments
Closed

Heap-buffer-overflow src/jsiEval.c:1726 in jsiEvalCodeSub #58

hope-fly opened this issue Dec 24, 2021 · 2 comments

Comments

@hope-fly
Copy link

hope-fly commented Dec 24, 2021

Jsish revision

Commit: 9fa798e

Version: v3.5.0

Build platform

Ubuntu 18.04.5 LTS (Linux 5.4.0-44-generic x86_64)

Build steps
export CFLAGS='-fsanitize=address'
make
Test case
assert(!Object.isFrozen(this));

Execution steps & Output
$ ./jsish/jsish poc.js
=================================================================
========ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6250000000f8 at pc 0x564ace319901 bp 0x7ffc53fdd700 sp 0x7ffc53fdd6f0
READ of size 8 at 0x6250000000f8 thread T0
    #0 0x564ace319900 in jsiEvalCodeSub src/jsiEval.c:1726
    #1 0x564ace31c15e in jsi_evalcode src/jsiEval.c:2204
    #2 0x564ace320274 in jsi_evalStrFile src/jsiEval.c:2665
    #3 0x564ace00f66a in Jsi_Main src/jsiInterp.c:936
    #4 0x564ace81403a in jsi_main src/main.c:47
    #5 0x7fe7b7384bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
    #6 0x564acdfa3969 in _start (/usr/local/bin/jsish+0xe8969)

0x6250000000f8 is located 8 bytes to the left of 8192-byte region [0x625000000100,0x625000002100)
allocated by thread T0 here:
    #0 0x7fe7b7ff3f30 in realloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdef30)
    #1 0x564ace014972 in Jsi_Realloc src/jsiUtils.c:47

SUMMARY: AddressSanitizer: heap-buffer-overflow src/jsiEval.c:1726 in jsiEvalCodeSub
Shadow bytes around the buggy address:
  0x0c4a7fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c4a7fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
  0x0c4a7fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
========ABORTING

Credits: Found by OWL337 team.

@hope-fly
Copy link
Author

This issue may have a correlation with #56, but I'm not for sure.

@pcmacdon
Copy link
Owner

No, this is in a completely different area of the code than #56.
But, I can not reproduce the error. In fact, the "assert" and it's arguments will be elided out unless you enable asserts.
So this does nothing when I execute it. If I turn on asserts, I get a syntax errror on "isFrozen", as you'd expect.

jsish -t 58.jsi 
Test 58.jsi ERROR: 'isFrozen' sub-commands are: prototype.
[FAIL] 58.jsi

Moreover, the code at jsiEval.c:1726 is for "typeof" handling, which is not in this test.
Will close for now.

pcmacdon pushed a commit that referenced this issue Dec 26, 2021
FossilOrigin-Name: c4bb805d478675766d42aec1c623d638426ca7d346e7be35d09df3523c4ab784
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