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
Our team at FuzzingLabs identified a non-compliance issue in the KECCAK256 implementation. During the execution of the this opcode, LEVM incorrectly allocates memory even when the size parameter is zero. This behavior deviates from expected EVM standards as implemented in widely adopted EVMs like REVM and Geth. Allocating memory in this scenario is unnecessary and results in an inflated memory size (MSIZE) and unnecessary gas consumption.
thread 'test_non_compliance_keccak256' panicked at crates/vm/levm/tests/edge_case_tests.rs:14:5:
assertion `left == right` failed
left:32
right:0
stack backtrace:0: rust_begin_unwind
at /rustc/8adb4b30f40e6fbd21dc1ba26c3301c7eeb6de3c/library/std/src/panicking.rs:665:51: core::panicking::panic_fmt
at /rustc/8adb4b30f40e6fbd21dc1ba26c3301c7eeb6de3c/library/core/src/panicking.rs:76:142: core::panicking::assert_failed_inner3: core::panicking::assert_failed
at /home/mhoste/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:373:54: edge_case_tests::test_non_compliance_keccak256
at ./tests/edge_case_tests.rs:14:55: edge_case_tests::test_non_compliance_keccak256::{{closure}}
at ./tests/edge_case_tests.rs:9:356: core::ops::function::FnOnce::call_once
at /home/mhoste/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:57: core::ops::function::FnOnce::call_once
at /rustc/8adb4b30f40e6fbd21dc1ba26c3301c7eeb6de3c/library/core/src/ops/function.rs:250:5
The text was updated successfully, but these errors were encountered:
Our team at FuzzingLabs identified a non-compliance issue in the KECCAK256 implementation. During the execution of the this opcode, LEVM incorrectly allocates memory even when the
size
parameter is zero. This behavior deviates from expected EVM standards as implemented in widely adopted EVMs like REVM and Geth. Allocating memory in this scenario is unnecessary and results in an inflated memory size (MSIZE
) and unnecessary gas consumption.Root cause
size == 0
, the memory is unnecessarily extended up to theoffset
.For example:
offset = 1
,size = 0
.KECCAK256
: No changes,MSIZE
should return0
.KECCAK256
: Memory is extended to 32 bytes, andMSIZE
incorrectly returns32
.Recommendations
To align LEVM with expected EVM behavior:
op_keccak256
implementation to check ifsize = 0
before performing memory allocation.size = 0
, and return the Keccak256 hash of an empty byte array.Step to reproduce
Payload
Add to test :
Backtrace
The text was updated successfully, but these errors were encountered: