Open
Description
Credit : Sunghoon Jang, Jeonil Ji
Escargot
- OS: Ubuntu 18.04
Describe the bug
Out-of-Bounds write
Test case
Test code to reproduce the behavior:
set.txt
rename .txt -> .js before use
Analysis

- A SIGABRT occurred in this code.

- After building Escargot in debug mode, I confirmed that an out-of-bounds (OOB) write occurred while accessing index 67108737.

- The result of
n / wordSize
is 67108737, leading to OOB access at bits[67108737].- 67108737 = 0x3ffff81
- To check the value of
n
, I examined backtrace#1, where theset()
function is called.

- I confirmed that the
set()
function usesch - chunkLo
as an argument.


- The value of
n = ch - chunkLo
- A negative value (0xffffe055) was passed to n.

third_party/yarr/BitSet.h:150 asm
- I confirmed that the argument values are being pushed onto the stack inside the set function.
- The value of n (
0xffffe055
) is stored at rbp-0x10.

third_party/yarr/BitSet.h
- I verified that
n / wordSize
is being used as the index ofbits
.

- Since
wordSize
= 2^6, it performs a shr 6 operation internally.

- The value of rax contains n (
0xffffe055
). - After the
n / wordSize
operation, the result0x3ffff81
is stored in rdx. - Then, an attempt is made to access
bits[0x3ffff81]
, resulting in the OOB.