Skip to content
DoS Audit finding Intermediate

An already executed InTxTracker can still be added

The AddToInTxTracker function does not check whether an inbound transaction tracker has already been executed, so anyone can re-add trackers for transactions that were already processed. Observers keep fetching and voting on these duplicate trackers, and because the vote digest already exists the vote fails and the tracker is never removed, so an attacker could flood the network with such trackers and cause congestion.

zhaojie Follow with MevSec and berndartmueller

Originally disclosed on Code4rena

Submitted by zhaojie, also found by MevSec and berndartmueller

Anyone can add InTxTracker has been carried out, the node/observer will still deal with executive InTxTracker, Tx will not be repeated(The status of the vote has been changed and the vote cannot pass) ,but an attacker can cause network congestion.

Proof of Concept

A new architecture use Permissionless Tx Validation Model, anyone can add an InTxTracker, but the AddToInTxTracker function does not verify that an InTxTracker has already been executed, so a Tx that has already been executed can be added again. Since the executed Txs are normal Tx, they can be verified by proof and can be added by anyone.

The observer through GetInboundTrackersForChain access to all the InTxTracker, then parse the Tx content, then MsgVoteOnObservedInboundTx messages sent to a vote, after voting by creates CCTX, Finally execute OutBoundTx.

After the CCTX is created, the InTxTracker will be removed. If added again at this time, the observer still retrieves the Tx and creates a vote, since VoteOnObservedInboundTx uses msg.Digest as the index for voting, so duplicate messages cannot be voted, and eventually CCTX will not be created and will not be executed.

func (k msgServer) VoteOnObservedInboundTx(....) {
    ....
	cctx := k.CreateNewCCTX(ctx, msg, index, tssPub, types.CctxStatus_PendingInbound, observationChain, receiverChain)
	defer func() {
		EmitEventInboundFinalized(ctx, &cctx)
		// #nosec G701 always positive
		cctx.InboundTxParams.InboundTxFinalizedZetaHeight = uint64(ctx.BlockHeight())
@>		k.RemoveInTxTrackerIfExists(ctx, cctx.InboundTxParams.SenderChainId, cctx.InboundTxParams.InboundTxObservedHash)
		k.SetCctxAndNonceToCctxAndInTxHashToCctx(ctx, cctx)
	}()
}

But here’s the problem: failing InTxTracker are not deleted, InTxTracker is deleted after a VoteOnObservedInboundTx vote successfully creates a CCTX, but will not be deleted if a cctx is not created ,they are always available to observers, and they keep on executing and failing, causing congestion when there are a large number of these invalid InTxTracker on the network.

An attacker can add all the executed InTxTracker to the network and attack the network, which can make the network not work.

func (k msgServer) AddToInTxTracker(goCtx context.Context, msg *types.MsgAddToInTxTracker) (*types.MsgAddToInTxTrackerResponse, error) {
	ctx := sdk.UnwrapSDKContext(goCtx)
	chain := k.zetaObserverKeeper.GetParams(ctx).GetChainFromChainID(msg.ChainId)
	if chain == nil {
		return nil, observertypes.ErrSupportedChains
	}

	adminPolicyAccount := k.zetaObserverKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_group1)
	isAdmin := msg.Creator == adminPolicyAccount
	isObserver := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain)

	isProven := false
	//@audit isObserver isAdmin does not verify proof if one is true
	if !(isAdmin || isObserver) && msg.Proof != nil {
		txBytes, err := k.VerifyProof(ctx, msg.Proof, msg.ChainId, msg.BlockHash, msg.TxIndex)
		if err != nil {
			return nil, types.ErrProofVerificationFail.Wrapf(err.Error())
		}

		if common.IsEVMChain(msg.ChainId) {
			err = k.VerifyEVMInTxBody(ctx, msg, txBytes)
			if err != nil {
				return nil, types.ErrTxBodyVerificationFail.Wrapf(err.Error())
			}
		} else {
			return nil, types.ErrTxBodyVerificationFail.Wrapf(fmt.Sprintf("cannot verify inTx body for chain %d", msg.ChainId))
		}
		isProven = true
	}

	// Sender needs to be either the admin policy account or an observer
	if !(isAdmin || isObserver || isProven) {
		return nil, errorsmod.Wrap(observertypes.ErrNotAuthorized, fmt.Sprintf("Creator %s", msg.Creator))
	}

    //@audit need to verify that InTxTracker has been executed

	k.SetInTxTracker(ctx, types.InTxTracker{
		ChainId:  msg.ChainId,
		TxHash:   msg.TxHash,
		CoinType: msg.CoinType,
	})
	return &types.MsgAddToInTxTrackerResponse{}, nil
}

Tools Used

VScode

Recommended Mitigation Steps

To verify that the InTxTracker has been executed.

DadeKuma (Lookout) commented:

Possible DoS with invalid transactions.

lumtis (ZetaChain) confirmed

0xean (Judge) decreased severity to Medium commented:

but an attacker can cause network congestion.

This does no qualify as H severity, it might qualify to M severity assuming it could lead to a DOS.


The original report as published on Code4rena, by zhaojie. 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 AddToInTxTracker handler stores a tracker without checking whether that inbound transaction was already observed and executed, and failed trackers are never removed.

Impact

An attacker could add many already-executed trackers to congest the network, though the judge noted this only might qualify as a denial of service.

What the attacker needed

None

The fix

The AddToInTxTracker function should verify that the inbound transaction has not already been executed before storing the tracker.

How it was found

  1. Add an InTxTracker for a transaction that has already been executed.
  2. Observers fetch the tracker through GetInboundTrackersForChain and send a vote message.
  3. The vote fails because the digest was already used, so no CCTX is created.
  4. The tracker is not removed and observers keep processing it, causing congestion.

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 tracker is a note telling the network to look at a transaction on another chain. The code lets anyone add a note for a transaction that was already handled, and when the network tries to vote on it again the vote is rejected, but the note is never cleaned up. An attacker could add many of these useless notes so the network spends time on them and slows down.

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 zhaojie

View all

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