MsgCreate2 deviates from EVM spec causing a large range of address not reachable
The MsgCreate2 message type defines the salt as a 64-bit unsigned integer, whereas the EVM CREATE2 opcode expects a 32-byte salt. This means many valid contract addresses cannot be reached through the CLI or gRPC flows that use MsgCreate2.
Submitted by oakcobalt
Proof of Concept
Based on EIP-1014, salt used in create2 is always 32 bytes.
The issue is MsgCreate2 defines salt as uin64. This means a large range of address is not reachable in any flow that uses MsgCreate2.
// MsgCreate2 is a message to create a contract with the CREATE2 opcode.
type MsgCreate2 struct {
// Sender is the that actor that signed the messages
Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"`
// Code is hex encoded raw contract bytes code.
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
// Salt is a random value to distinguish contract creation.
|> Salt uint64 `protobuf:"varint,3,opt,name=salt,proto3" json:"salt,omitempty"`
// Value is the amount of fee denom token to transfer to the contract.
Value cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value"`
// AccessList is a predefined list of Ethereum addresses and their corresponding storage slots that a transaction will interact with during its execution. can be none
AccessList []AccessTuple `protobuf:"bytes,5,rep,name=access_list,json=accessList,proto3" json:"access_list"`
}
In minievm, MsgCreate2 is currently used as create2 input in CLI and gRPC flows.
create2fromCLI:
//x/evm/client/cli/tx.go
func Create2Cmd(ac address.Codec) *cobra.Command {
...
|> salt, err := strconv.ParseUint(args[0], 10, 64) //@audit salt is parsed as uint64
if err != nil {
return errors.Wrap(err, "failed to parse salt")
}
create2fromgRPC:
func (c *msgClient) Create2(ctx context.Context, in *MsgCreate2, opts ...grpc.CallOption) (*MsgCreate2Response, error) {
out := new(MsgCreate2Response)
err := c.cc.Invoke(ctx, Msg_Create2_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
Impact
- A large range of address not reachable through
CLIandgRPC. This prevents certainCLI/gRPCbased contracts deployments that would have been valid. This causes predictable failures for legitimate use cases. - Compatibility issue with other EVM based tooling.
Recommended mitigation steps
Consider allowing to use string for salt input.
leojin (Initia) disputed and commented:
There doesn’t seem to be any other issues, just support for a smaller range of salts.
LSDan (judge) decreased severity to Medium and commented:
This is at root a compatibility issue that will impact the expected functionality of the chain. I don’t think as reported it qualifies for high risk, but it does strike me as a valid medium.
Fixed here.
Added salt range check.
Status: Unmitigated. Full details in reports from 0xAlix2, berndartmueller and Franfran, and also included in the Mitigation Review section below.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the MsgCreate2 protobuf definition uses uint64 for the salt field instead of a 32-byte value, and the CLI parses the salt as a 64-bit unsigned integer.
Impact
A large range of contract addresses cannot be reached through CLI and gRPC, causing predictable failures for legitimate deployments and compatibility issues with other EVM tooling.
What the attacker needed
Use of CLI or gRPC create2 flow
The fix
The salt input should be changed to a string or 32-byte value to match the EVM specification; the report notes a fix was made and later a salt range check was added, but the mitigation review status is unmitigated.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a smart contract is deployed using the CREATE2 opcode, a value called a salt is combined with the contract code to determine the contract's address. The Ethereum standard says this salt must be 32 bytes long, but this project's message type only allows a 64-bit number, which is much smaller. As a result, many possible contract addresses cannot be created through the command-line or gRPC interfaces.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.