-
Notifications
You must be signed in to change notification settings - Fork 502
Open
Description
Description
Wasm3 fails to validate the type of the argument passed to the br_table
instruction. According to the WebAssembly specification, the index parameter used in br_table
must have the type i32
. However, Wasm3 does not enforce this validation, allowing an argument with an invalid type (e.g., i64
) to bypass validation and execute, leading to undefined behavior.
Environment
$ ./wasm3 --version
Wasm3 v0.5.0 on x86_64
Build: May 28 2024 20:38:13, Ubuntu Clang 19.0.0
Steps to Reproduce
Run the following WebAssembly module:
(module
(func $main (result i32)
(local $index i64)
(local.set $index (i64.const 2))
(block $block0
(block $block1
(block $block2
(block $block3
(br_table $block0 $block1 $block2 $block3 (local.get $index))
)
i32.const 3
return
)
i32.const 2
return
)
i32.const 1
return
)
i32.const 0
)
(export "main" (func $main))
)
Execute the module using Wasm3:
$ ./wasm3 --func main /path/to/program.wasm
Result: 2
Expected Behavior
According to the WebAssembly specification, the index parameter for the br_table
instruction must be of type i32
. If the argument type is invalid (e.g., i64
), the module must fail validation with an error such as:
br_table with non-i32 condition I64
Metadata
Metadata
Assignees
Labels
No labels