You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let minimum_word_size = (size + WORD_SIZE - 1) / WORD_SIZE; We can control size and give a value equal to usize::MAX. Since WORD_SIZE = 32, when we attempt to add usize::MAX + 32, we encounter an overflow because minimum_word_size is also a usize.
#[test]fntest_overflow_keccak256(){letmut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[51,63,61,32]));letmut current_call_frame = vm.call_frames.pop().unwrap();
vm.execute(&mut current_call_frame);}
Backtrace
---- tests::test_overflow_keccak256 stdout ----
thread 'tests::test_overflow_keccak256' panicked at crates/vm/levm/./src/opcode_handlers/keccak.rs:29:34:
attempt to add with overflow
stack backtrace:0: rust_begin_unwind
at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/panicking.rs:658:51: core::panicking::panic_fmt
at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/core/src/panicking.rs:74:142: core::panicking::panic_const::panic_const_add_overflow
at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/core/src/panicking.rs:181:213: ethereum_rust_levm::opcode_handlers::keccak::<impl ethereum_rust_levm::vm::VM>::op_keccak256
at ./src/opcode_handlers/keccak.rs:29:344: ethereum_rust_levm::vm::VM::execute
at ./src/vm.rs:170:385: lib::tests::test_overflow_keccak256
at ./tests/tests.rs:50:56: lib::tests::test_overflow_keccak256::{{closure}}
at ./tests/tests.rs:47:297: core::ops::function::FnOnce::call_once
at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/core/src/ops/function.rs:250:58: core::ops::function::FnOnce::call_once
at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/core/src/ops/function.rs:250:5
The text was updated successfully, but these errors were encountered:
Our team at FuzzingLabs discovered a bug in the op_keccak256 function, this bug can lead to a panic when calculating
minimum_word_size
.Root cause
let minimum_word_size = (size + WORD_SIZE - 1) / WORD_SIZE;
We can controlsize
and give a value equal tousize::MAX
. SinceWORD_SIZE = 32
, when we attempt to addusize::MAX + 32
, we encounter an overflow becauseminimum_word_size
is also ausize
.Step to reproduce
Payload
Add to test :
Backtrace
The text was updated successfully, but these errors were encountered: