Skip to content
DoS Audit finding Intermediate

When updating gas, if one chain fails, the others should continue to be updated instead of being skipped.

The gas price update loop for cross-chain transactions returns early on the first error, so if one chain's gas stability pool has insufficient balance, the remaining chains are skipped. An attacker could cause a chain's gas stability pool to be depleted, preventing gas price updates for other chains.

p0wd3r Follow with oakcobalt, dontonka and 1 other

Originally disclosed on Code4rena

Submitted by p0wd3r, also found by oakcobalt, dontonka, and berndartmueller

Due to an expected error occurring in one chain, the gas for the other chains cannot be updated.

Proof of Concept

IterateAndUpdateCctxGasPrice is used to periodically update the gas price of cctx. It iterates through all cctx in all chains to update their gas price.

https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/node/x/crosschain/keeper/abci.go#L34-L53

	// iterate all chains' pending cctx
	chains := common.DefaultChainsList()
	for _, chain := range chains {
		res, err := k.CctxAllPending(sdk.UnwrapSDKContext(ctx), &types.QueryAllCctxPendingRequest{
			ChainId: chain.ChainId,
		})
		if err != nil {
			return err
		}

		// iterate through all pending cctx
		for _, pendingCctx := range res.CrossChainTx {
			if pendingCctx != nil {
				_, _, err := k.CheckAndUpdateCctxGasPrice(ctx, *pendingCctx, gasPriceIncreaseFlags)
				if err != nil {
					return err
				}
			}
		}
	}

One possible error that can be returned in CheckAndUpdateCctxGasPrice is insufficient balance in the GasStabilityPool.

https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/node/x/crosschain/keeper/abci.go#L107-L112

	if err := k.fungibleKeeper.WithdrawFromGasStabilityPool(ctx, chainID, additionalFees.BigInt()); err != nil {
		return math.ZeroUint(), math.ZeroUint(), cosmoserrors.Wrap(
			types.ErrNotEnoughFunds,
			fmt.Sprintf("cannot withdraw %s from gas stability pool", additionalFees.String()),
		)
	}

The GasStabilityPool is only replenished when an outbound transaction is finalized.

https://github.com/code-423n4/2023-11-zetachain/blob/main/repos/node/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go#L131-L136

	// Fund the gas stability pool with the remaining funds
	if err := k.FundGasStabilityPoolFromRemainingFees(ctx, *cctx.GetCurrentOutTxParam(), msg.OutTxChain); err != nil {
		log.Error().Msgf(
			"VoteOnObservedOutboundTx: CCTX: %s Can't fund the gas stability pool with remaining fees %s", cctx.Index, err.Error(),
		)
	}

Therefore, during the execution of IterateAndUpdateCctxGasPrice, outbound cctx may not have been finalized yet, leading to a possible scenario of insufficient balance in the GasStabilityPool, which is an expected occurrence. However, in the current implementation, if the GasStabilityPool of one chain is insufficient, the function directly returns, and the remaining chains in the loop are not processed. For other chains, the GasStabilityPool might be sufficient, and they should not be neglected.

Tools Used

VScode

Recommended Mitigation Steps

If CheckAndUpdateCctxGasPrice returns an error, skip the loop for that cctx and continue with the outer loop for the chain.

lumtis (ZetaChain) confirmed


The original report as published on Code4rena, by p0wd3r. 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

What the attacker needed

Ability to deplete a gas stability pool

The fix

The code should skip the failing chain and continue updating the others.

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 cross-chain system periodically updates the gas price for pending transactions on many chains. If updating one chain fails (for example, because a fund pool is empty), the code stops and never updates the other chains. This means a problem on one chain can block updates on all others.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by p0wd3r

View all

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

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.