Skip to content

fix: expand memory before slicing initcode in CREATE2 wrapper#293

Merged
RealiCZ merged 1 commit into
cz/fix/create2from
cz/fix/07
May 11, 2026
Merged

fix: expand memory before slicing initcode in CREATE2 wrapper#293
RealiCZ merged 1 commit into
cz/fix/create2from
cz/fix/07

Conversation

@RealiCZ
Copy link
Copy Markdown
Collaborator

@RealiCZ RealiCZ commented May 11, 2026

Summary

Important

Post-mainnet follow-up fix

Fix an out-of-bounds memory access in the storage_gas_ext::create<IS_CREATE2> wrapper.

The wrapper sliced initcode out of interpreter memory via memory.slice_len(offset, len) before memory was expanded. The canonical revm CREATE2 path called later does call resize_memory!, but by then the slice has already been taken — so a CREATE2 whose (offset, len) extended past the current memory size could read past the allocated region in our wrapper.

Test plan

  • New crates/mega-evm/tests/rex4/create_safety.rs covering CREATE2 with (offset, len) extending past current memory, including the clean-OOG and successful-expansion paths.
  • cargo test -p mega-evm (run before pushing).
  • cargo clippy --workspace --lib --examples --tests --benches --all-features --locked and cargo fmt --all --check.

@RealiCZ RealiCZ added the spec:stable Touches stable spec code — must not change behavior label May 11, 2026
@RealiCZ RealiCZ requested a review from Troublor as a code owner May 11, 2026 02:31
@RealiCZ RealiCZ added comp:core Changes to the `mega-evm` core crate rust Pull requests that update rust code labels May 11, 2026
@RealiCZ RealiCZ added spec:unchanged No change to any `mega-evm`'s behavior api:unchanged No change to the public interface or API and removed spec:stable Touches stable spec code — must not change behavior labels May 11, 2026
@RealiCZ RealiCZ merged commit 08e745c into cz/fix/create2 May 11, 2026
82 of 102 checks passed
@RealiCZ RealiCZ deleted the cz/fix/07 branch May 11, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:unchanged No change to the public interface or API comp:core Changes to the `mega-evm` core crate rust Pull requests that update rust code spec:unchanged No change to any `mega-evm`'s behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants