Skip to content
Business logic Audit finding Intermediate

Outbound zEVM cross-chain messages ignore the user-specified gas limit and may fail with an out-of-gas error

Cross-chain Zeta messages sent from the zEVM ignore the user-specified destination gas limit and instead use a hardcoded value of 90000. This can cause the outbound transaction to fail with an out-of-gas error, aborting the cross-chain transaction without refunding the sender.

berndartmueller Follow with dontonka

Originally disclosed on Code4rena

Submitted by berndartmueller, also found by dontonka

Cross-chain Zeta messages originating from the zEVM have the user-specified destination gas limit ignored (hardcoded to 90000), potentially causing the transaction to fail with an out-of-gas error.

As a result, the cctx is aborted without refunding the sender, thus causing the sender to lose funds.

Proof of Concept

zEVM transactions are post-processed in the PostTxProcessing function of the x/crosschain module. Specifically, the goal is to parse and process ZetaSent and ZRC-20 Withdrawal events and send them to the corresponding external receiver chains.

Any emitted ZetaSent events are parsed and processed in the ProcessZetaSentEvent function. This event is emitted by the ZetaConnectorZEVM.send function to send a cross-chain message to an external chain. The message input, ZetaInterfaces.SendInput, allows the sender to specify the destinationGasLimit to ensure sufficient gas is used, in case the cross-chain message, once received by the onReceive function of the ZetaConnector contract on the receiver chain (e.g., ZetaConnectorEth or ZetaConnectorNonEth) calls the destinationAddress’s onZetaMessage function.

However, this user-specified gas limit (destinationGasLimit) is not used, instead, it is hardcoded in line 224 to 90000.

172: func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaConnectorZEVMZetaSent, emittingContract ethcommon.Address, txOrigin string) error {
...  	// [...]
212:
213: 	// Bump gasLimit by event index (which is very unlikely to be larger than 1000) to always have different ZetaSent events msgs.
214: 	msg := types.NewMsgVoteOnObservedInboundTx(
215: 		"",
216: 		emittingContract.Hex(),
217: 		senderChain.ChainId,
218: 		txOrigin, toAddr,
219: 		receiverChain.ChainId, /
220: 		amount,
221: 		"",
222: 		event.Raw.TxHash.String(),
223: 		event.Raw.BlockNumber,
224: ❌	90000,
225: 		common.CoinType_Zeta,
226: 		"",
227: 		event.Raw.Index,
228: 	)
229: 	sendHash := msg.Digest()
230:
231: 	// Create the CCTX
232: 	cctx := k.CreateNewCCTX(ctx, msg, sendHash, tss.TssPubkey, types.CctxStatus_PendingOutbound, &senderChain, receiverChain)
...  	// [...]
246: }

Please note that the observer’s EVM signer lower-bounds the gas limit to 100k.

As the transactions gas limit is set to 90k, and subsequently overwritten to the lower bound of 100k, the transaction potentially fails with an out-of-gas error, preventing the transaction from being processed.

The sender of the cross-chain Zeta message may have anticipated this and thus specified a higher destinationGasLimit in the first place to ensure the transaction succeeds, which is unfortunately ignored.

Recommended mitigation steps

Consider using the user-specified destinationGasLimit instead of hardcoding the gas limit to 90000.

lumtis (ZetaChain) acknowledged


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

The code hardcodes the destination gas limit to 90000 instead of using the user-supplied destinationGasLimit from the event.

Impact

The cross-chain transaction may fail with an out-of-gas error and be aborted without refunding the sender, causing loss of funds.

What the attacker needed

Sender uses ZetaConnectorZEVM.send; destination call needs more than 100k gas

The fix

The code should use the user-specified destinationGasLimit instead of hardcoding the gas limit to 90000.

How it was found

  1. A user calls ZetaConnectorZEVM.send with a chosen destinationGasLimit.
  2. The ZetaSent event is parsed in ProcessZetaSentEvent.
  3. The code builds a message with a hardcoded gas limit of 90000 instead of the user's value.
  4. The observer's EVM signer raises the limit to a 100k lower bound.
  5. If the destination call needs more than that, the outbound transaction fails with out-of-gas.
  6. The cross-chain transaction is aborted without refunding the sender.

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 you send a message from one blockchain to another, you can say how much computing effort (gas) the receiving side may use. This report found that the system ignored that setting and always used a small fixed amount, so the message could run out of gas and fail, and the sender's funds were not returned.

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 ZetaChain

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.