Skip to content
Business logic Audit finding Intermediate

Zeta token supply checker incorrectly classifies in-transit cctxs as settled resulting in misleading checks

The Zeta token supply checker incorrectly treats cross-chain transactions as settled once they are added to the OutTxTracker, even though they may still be pending in the EVM mempool. This can cause false positives, suggesting a supply mismatch when none exists.

berndartmueller Follow

Originally disclosed on Code4rena

Submitted by berndartmueller

The Zeta token supply checker delivers false positives, suggesting that there is a Zeta token supply mismatch.

Proof of Concept

The GetPendingCCTXInTransit function in the ZetaSupplyChecker is supposed to return all cctxs that are currently in transit, i.e., cctxs that are pending and soon to be sent to the receiving chains. These pending cctx’s are then used to determine the amount of in-transit Zeta tokens (zetaInTransit), subsequently used in the ValidateZetaSupply function to check and validate the Zeta token supply.

Internally, the GetPendingCCTXInTransit function queries all pending cctxs for the receivingChains from the ZetaChain RPC in line 210. Thereafter, the cctxs are filtered in lines 221-233 by removing all cctxs that have been added to the OutTxTracker.

207: func (zs *ZetaSupplyChecker) GetPendingCCTXInTransit(receivingChains []common.Chain) []*types.CrossChainTx {
208: 	cctxInTransit := make([]*types.CrossChainTx, 0)
209: 	for _, chain := range receivingChains {
210: 		cctx, err := zs.zetaClient.GetAllPendingCctx(chain.ChainId)
211: 		if err != nil {
212: 			continue
213: 		}
214: 		nonceToCctxMap := make(map[uint64]*types.CrossChainTx)
215: 		for _, c := range cctx {
216: 			if c.GetInboundTxParams().CoinType == common.CoinType_Zeta {
217: 				nonceToCctxMap[c.GetCurrentOutTxParam().OutboundTxTssNonce] = c
218: 			}
219: 		}
220:
221: 		trackers, err := zs.zetaClient.GetAllOutTxTrackerByChain(chain, Ascending)
222: 		if err != nil {
223: 			continue
224: 		}
225: 		for _, tracker := range trackers {
226: 			zs.logger.Info().Msgf("tracker exists for nonce: %d , removing from supply checks", tracker.Nonce)
227: 			delete(nonceToCctxMap, tracker.Nonce)
228: 		}
229: 		for _, c := range nonceToCctxMap {
230: 			if c != nil {
231: 				cctxInTransit = append(cctxInTransit, c)
232: 			}
233: 		}
234: 	}
235: 	return cctxInTransit
236: }

The reasoning for this is that once a cctx has been broadcasted to the receiver chain by the observers, the cctx is added to the OutTxTracker. As a result, the cctx is no longer considered to be in transit, the Zeta token supply on the receiver chain is updated (via minting or unlocking) and the update Zeta token supply is either included in the ethLockedAmount or externalChainTotalSupply.

However, the assumption that when a cctx is broadcasted to the receiver chain and included in the OutTxTracker, the cctx is no longer in transit is only partially correct. Once the transaction is broadcasted, it first stays in the EVM mempool until it is included in a block. Only then, the transaction is executed in the EVM, the state transition is applied and the Zeta token supply updated.

Consequently, the in-transit Zeta token is not correctly tracked, and the supply checker can not correctly validate the Zeta token supply.

Recommended mitigation steps

I’m not entirely sure how to fix this issue and if it’s even viable to do so. Rather, the supply checker should be allowed to work with a margin of error, i.e., the supply checker should be allowed to be off by a certain amount of Zeta tokens.

DadeKuma (Lookout) commented:

Pending transactions in mempool might break the max supply invariant.

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

Likely the supply checker assumes that a cross-chain transaction is settled as soon as it is added to the OutTxTracker, without accounting for the delay before the transaction is included in a block and executed.

Impact

The supply checker may report false positives, incorrectly flagging a Zeta token supply mismatch when there is none.

What the attacker needed

None

The fix

The supply checker should be allowed to work with a margin of error, as the reporter suggests, because a precise fix may not be viable.

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.

A supply checker is a program that verifies the total number of tokens in circulation. It mistakenly assumed that once a transfer was broadcast to another blockchain, it was complete, but the transfer might still be waiting in a queue (mempool) before being finalised. This led to incorrect warnings about the token supply.

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.