Skip to content
Business logic Audit finding Intermediate

COINBASE opcode returns an empty address instead of the block proposer resulting in incompatibility with the EVM

The COINBASE opcode in minievm returns an empty address instead of the block proposer, making it incompatible with the EVM. This could cause issues for Solidity contracts that rely on the coinbase address.

berndartmueller Follow

Originally disclosed on Code4rena

Submitted by berndartmueller

EVM’s COINBASE opcode (https://www.ethervm.io/#41) is supposed to return the block proposer. However, minievm sets Coinbase to an empty address in line 131. This causes incompatible behavior with the EVM and potential issues with Solidity contracts that might use the coinbase address.

Proof of Concept

minievm:x/evm/keeper/context.go#L131

058: func (k Keeper) buildBlockContext(ctx context.Context, defaultBlockCtx vm.BlockContext, evm *vm.EVM, fee types.Fee) (vm.BlockContext, error) {
059: 	sdkCtx := sdk.UnwrapSDKContext(ctx)
060: 	baseFee, err := k.baseFee(ctx, fee)
061: 	if err != nil {
062: 		return vm.BlockContext{}, err
063: 	}
064:
065: 	return vm.BlockContext{
...: 		// [...]
131:❌		Coinbase:    common.Address{},
132: 		Difficulty:  big.NewInt(0),
133: 		BlobBaseFee: big.NewInt(0),
134: 	}, nil
135: }

The GASLIMIT EVM opcode uses this GasLimit value to return the block gas limit:

core/vm/instructions.go#L473-L476

func opCoinbase(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
	scope.Stack.push(new(uint256.Int).SetBytes(interpreter.evm.Context.Coinbase.Bytes()))
	return nil, nil
}

Recommended mitigation steps

Consider setting Coinbase to stakingKeeper.GetValidatorByConsAddr(), similar to how Evmos does it here and here.

leojin (Initia) disputed and commented:

Its intended spec to provide zero address.


The original report as published on Code4rena, by berndartmueller. 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 block context is built with a hardcoded empty address for Coinbase instead of fetching the actual block proposer.

Impact

Contracts that use the coinbase address could malfunction or produce unexpected results, though the project team disputes this and says the zero address is intended.

What the attacker needed

None

The fix

The report recommends setting Coinbase to the validator address from the staking keeper, similar to Evmos, but the project disputed this and stated the zero address is intended.

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.

The COINBASE opcode is supposed to tell a smart contract who mined the current block. In this system it always returns an empty address, so contracts that expect a real address may behave incorrectly.

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 berndartmueller

View all

97 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.