fix: expand memory before slicing initcode in CREATE2 wrapper#293
Merged
Conversation
Troublor
approved these changes
May 11, 2026
flyq
approved these changes
May 11, 2026
Troublor
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 callresize_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
crates/mega-evm/tests/rex4/create_safety.rscovering 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 --lockedandcargo fmt --all --check.