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
#[test]fntest_overflow_swap(){letmut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[48,144]));letmut current_call_frame = vm.call_frames.pop().unwrap();
vm.execute(&mut current_call_frame);}
Backtrace
---- tests::test_overflow_swap stdout ----
thread 'tests::test_overflow_swap' panicked at crates/vm/levm/src/opcode_handlers/exchange.rs:32:40:
attempt to subtract 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_sub_overflow
at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/core/src/panicking.rs:181:213: ethereum_rust_levm::opcode_handlers::exchange::<impl ethereum_rust_levm::vm::VM>::op_swap
at ./src/opcode_handlers/exchange.rs:32:404: ethereum_rust_levm::vm::VM::execute
at ./src/vm.rs:207:215: lib::tests::test_overflow_swap
at ./tests/tests.rs:82:56: lib::tests::test_overflow_swap::{{closure}}
at ./tests/tests.rs:79:247: 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 (@FuzzingLabs) discovered a bug was identified in the op_swap function, we can trigger an overflow due to the lack of checks.
Root cause
stack_top_index - 1
we trigger an underflow because there is no check if stack_top_index ≠ 0.Step to reproduce
Payload
Add to [test](https://github.com/lambdaclass/lambda_ethereum_rust/blob/main/crates/vm/levm/tests/tests.rs) :
Backtrace
The text was updated successfully, but these errors were encountered: