Skip to content
Business logic Audit finding Intermediate

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.

oakcobalt Follow

Originally disclosed on Code4rena

Submitted by oakcobalt

https://github.com/initia-labs/minievm/blob/744563dc6a642f054b4543db008df22664e4c125/x/evm/client/cli/tx.go#L89

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"`
}

https://github.com/initia-labs/minievm/blob/744563dc6a642f054b4543db008df22664e4c125/x/evm/types/tx.pb.go#L171

In minievm, MsgCreate2 is currently used as create2 input in CLI and gRPC flows.

  1. create2 from CLI:
//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")
			}

https://github.com/initia-labs/minievm/blob/744563dc6a642f054b4543db008df22664e4c125/x/evm/client/cli/tx.go#L115

  1. create2 from gRPC:
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
}

https://github.com/initia-labs/minievm/blob/744563dc6a642f054b4543db008df22664e4c125/api/minievm/evm/v1/tx_grpc.pb.go#L60

Impact

  1. A large range of address not reachable through CLI and gRPC. This prevents certain CLI/gRPC based contracts deployments that would have been valid. This causes predictable failures for legitimate use cases.
  2. 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.

beer-1 (Initia) commented:

Fixed here.

Initia mitigated:

Added salt range check.

Status: Unmitigated. Full details in reports from 0xAlix2, berndartmueller and Franfran, and also included in the Mitigation Review section below.


The original report as published on Code4rena, by oakcobalt. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by oakcobalt

View all

50 more disclosed reports, best first.

More from Initia Cosmos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.