WebAssembly / WebAssembly/wabt
[wasm2wat] Incorrect rejection of valid module
Open
@binji is already working on this.
Since Jun 17, 2020.
- Dominant language
- C++
- Stars
- 8.1k
- Forks
- 827
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 18
Description
Hi,
During fuzzing I found that the following module was consider invalid by wabt due to a leb128 parsing error. Binaryen choose to "reject" this module but precise that it is a valid module. Other tools like wasmer, wasmtime and wasm-tools valid this module.
Reproducing
Download:
reject_leb128_wabt.zip
WABT:
$ ./wasm-validate reject_leb128_wabt.wasm
0000016: error: unable to read u32 leb128: table_size
Other tools:
# binaryen
$ wasm-opt reject_leb128_wabt.wasm
wasm-opt reject_leb128_wabt2.wasm
[parse exception: inline string contains NULL (0). that is technically valid in wasm, but you shouldn't do it, and it's not supported in binaryen (at 0:34)]
Fatal: error parsing wasm
# wasmer
$ wasmer validate reject_leb128_wabt2.wasm
# wasm-tools
$ ./wasm-tools/target/debug/wasm-validate-rs reject_leb128_wabt.wasm
$ ./wasm-tools/target/debug/wasm2wat-rs reject_leb128_wabt.wasm
(module
(type (;0;) (func (param i32 i32 f64)))
(type (;1;) (func (param i32 i32) (result f64)))
(type (;2;) (func (param i32 i32)))
(type (;3;) (func (result f64)))
(type (;4;) (func (param i32) (result f64)))
(type (;5;) (func))
(import "env" "memoryBase" (global (;0;) i32))
(import "env" "memory" (memory (;0;) 0 2))
(import "e`v" "table" (table (;0;) 0 funcref))
(import "^^v" "tableBase" (global (;1;) i32))
)
Branch: master
commit: 15264cd20be3510058e56d1de5db1f32ae5364eb
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.