Skip to content
Business logic Audit finding Intermediate

Inbound transactions submitted to the InTxTracker that contain multiple ZetaSent and Deposited events are not processed correctly by the observers resulting in a loss of funds

The inbound transaction tracker only processes the first ZetaSent or Deposited event in a transaction, ignoring any additional events. An attacker could submit a transaction with multiple such events, causing the ignored events to never be voted on and the corresponding funds to be lost.

berndartmueller Follow

Originally disclosed on Code4rena

Submitted by berndartmueller

Observers miss out on voting on multiple ZetaSent and ERC-20 Deposited events that have been emitted in a single transaction, resulting in a loss of funds.

Proof of Concept

Anyone can submit inbound transactions to ZetaChain’s InTxTracker via the MsgAddToInTxTracker message in case the transaction was missed by the observers in the first place to ensure the transaction is processed.

The AddToInTxTracker function handles the MsgAddToInTxTracker message and ensures that the submitted transaction is a valid inbound transaction by verifying the provided Merkle proof. Additionally, the transaction’s To address must be the corresponding ZetaChain contract address (e.g., connector address for the Zeta coin type, or the custody contract address for the ERC-20 coin type).

ZetaChain observers continuously query this InTxTracker in the ObserveTrackerSuggestions function.

If the submitted inbound transaction’s coin type is CoinType_Zeta, the CheckReceiptForCoinTypeZeta function iterates all logs contained in the transaction’s receipt, as seen in lines 156-164.

144: func (ob *EVMChainClient) CheckReceiptForCoinTypeZeta(txHash string, vote bool) (string, error) {
145: connector, err := ob.GetConnectorContract()
...  // [...]
154:
155: var msg types.MsgVoteOnObservedInboundTx
156: for _, log := range receipt.Logs {
157: 	event, err := connector.ParseZetaSent(*log)
158: 	if err == nil && event != nil {
159: 		msg, err = ob.GetInboundVoteMsgForZetaSentEvent(event)
160: 		if err == nil {
161: ❌			break
162: 		}
163: 	}
164: }
...  // [...]
177: }

However, as soon as the first ZetaSent event is found and the corresponding MsgVoteOnObservedInboundTx message is successfully created, the for loop is exited in line 161 via the break statement.

Similarly, this also applies to the CheckReceiptForCoinTypeERC20 function in line 195, that processes Deposited events emitted by the ERC20Custody.deposit function.

As a consequence, if the transaction contains multiple ZetaSent events, only the first event is processed and voted upon in ZetaChain, and the other events are ignored.

Those ignored ZetaSent events are potentially never processed and the corresponding Zeta tokens that have been locked or burned in the connector contract are lost.

The use of “potentially” is due to the fact that the inbound transaction was missed by the observers (for any reason) in the first place, and therefore, the affected user submitted the transaction via the MsgAddToInTxTracker message.

Now the question is, how is it possible that multiple ZetaSent events are emitted when the transaction’s To address is the connector contract address?

This transaction could have been the result of a cross-chain message, and thus the ZetaConnectorEth.onReceive function is invoked. This function optionally calls the onZetaMessage function of the provided destinationAddress contract in lines 64-66.

52: function onReceive(
53:     bytes calldata zetaTxSenderAddress,
54:     uint256 sourceChainId,
55:     address destinationAddress,
56:     uint256 zetaValue,
57:     bytes calldata message,
58:     bytes32 internalSendHash
59: ) external override onlyTssAddress {
60:     bool success = IERC20(zetaToken).transfer(destinationAddress, zetaValue);
61:     if (!success) revert ZetaTransferError();
62:
63:     if (message.length > 0) {
64:         ZetaReceiver(destinationAddress).onZetaMessage(
65:             ZetaInterfaces.ZetaMessage(zetaTxSenderAddress, sourceChainId, destinationAddress, zetaValue, message)
66:         );
67:     }
68:
69:     emit ZetaReceived(zetaTxSenderAddress, sourceChainId, destinationAddress, zetaValue, message, internalSendHash);
70: }

Within this onZetaMessage function, the destination contract can repeatedly call the ZetaConnectorEth.send function to send cross-chain messages.

Et voilà, multiple ZetaSent events are emitted.

Similarly, this also applies for repeatedly calling the ERC20Custody.deposit function to deposit ERC-20 tokens.

Recommended mitigation steps

Consider removing the break statement in lines 161 and 195, and instead, process and vote on all ZetaSent and Deposited events.

lumtis (ZetaChain) confirmed


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 uses a break statement after processing the first matching event, so it never iterates over the remaining events in the transaction receipt.

What the attacker needed

Transaction missed by observers; user submits via MsgAddToInTxTracker; transaction contains multiple events

The fix

The break statement should be removed so that all ZetaSent and Deposited events are processed and voted on.

How it was found

  1. An observer misses an inbound transaction, so the user submits it via MsgAddToInTxTracker.
  2. The transaction contains multiple ZetaSent or Deposited events.
  3. The tracker's CheckReceiptForCoinTypeZeta or CheckReceiptForCoinTypeERC20 function iterates over logs.
  4. Upon finding the first matching event, it creates a vote message and breaks out of the loop.
  5. Subsequent events are ignored and never voted on, leading to lost funds.

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 transaction contains several events of the same type, the system only looks at the first one and stops. This means later events are never processed, so the money tied to them can be stuck forever. An attacker can deliberately create such a transaction to cause this loss.

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.