Headline
CVE-2023-30300: wasm2c hangs on certain inputs and cannot finish execution for a while. · Issue #2180 · WebAssembly/wabt
An issue in the component hang.wasm of WebAssembly 1.0 causes an infinite loop.
Certain hang.wasm causes wasm2c an infinite loop. wasm2c tries to access a memory that is not permitted instead of providing type mismatch error for a while.
^@asm^A^@^@^@^A^G^A`^B{^?^A~^C^B^A^@^@^L^A^H^@^@^@#^@^@^@^@^@^?
^A^G^Aàÿÿ^O^?^K
Program received signal SIGSEGV, Segmentation fault.
0x000000000047d8c6 in std::vector<wabt::TypeChecker::Label, std::allocator<wabt::TypeChecker::Label> >::_M_realloc_insert<wabt::LabelType&, std::vector<wabt::Type, std::allocator<wabt::Type> > const&, std::vector<wabt::Type, std::allocator<wabt::Type> > const&, unsigned long> (this=this@entry=0x7fffffffdd10, __position=__position@entry=non-dereferenceable iterator for std::vector, __args=@0x7fffffffd8d8: 0, __args=@0x7fffffffd8d8: 0, __args=@0x7fffffffd8d8: 0, __args=@0x7fffffffd8d8: 0) at /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_vector.h:1762
1762 return (__len < size() || __len > max_size()) ? max_size() : __len;
The expected output should be an error like other related tools would provide as below. To cite an example, run wasm2wat on the test file:
wasm2wat hang.wasm:
Expected_Behavior/hang.wasm:0000027: error: type mismatch in implicit return, expected [i64] but got []
A combination of afl-fuzz++4.03a and Wasmlike, an Xsmith-based random program generator produced the snippet of code that caused the crash. https://www.flux.utah.edu/project/xsmith