Skip to content
Business logic Audit finding Intermediate

The withdraw method in the Solana node doesn't increment the nonce when the withdrawal transaction fails

The withdraw methods in the Solana node do not increment the nonce when a withdrawal transaction fails, causing the nonce to remain stuck. This could prevent subsequent withdrawals from being processed correctly.

laksmana Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-04-zetachain-cross-chain-judging/issues/275

Found by

Laksmana

Summary

The missing increment nonce in the withdraw method can cause the nonce to get stuck when the withdraw transaction fails.

Root Cause

In the signer.go file, both the prepareWithdrawTx and prepareWithdrawSPLTx functions do not include a nonce increment instruction.

Go
func (signer *Signer) prepareWithdrawTx(
	ctx context.Context,
	cctx *types.CrossChainTx,
	height uint64,
	logger zerolog.Logger,
) (outboundGetter, error) {
	params := cctx.GetCurrentOutboundParam()
	// compliance check
	cancelTx := compliance.IsCCTXRestricted(cctx)
	if cancelTx {
		compliance.PrintComplianceLog(
			logger,
			signer.Logger().Compliance,
			true,
			signer.Chain().ChainId,
			cctx.Index,
			cctx.InboundParams.Sender,
			params.Receiver,
			"SOL",
		)
	}

	// sign gateway withdraw message by TSS
	msg, err := signer.createAndSignMsgWithdraw(ctx, params, height, cancelTx)
	if err != nil {
		return nil, errors.Wrap(err, "createAndSignMsgWithdraw error")
	}

	return func() (*Outbound, error) {
		// sign the withdraw transaction by relayer key
		inst, err := signer.createWithdrawInstruction(*msg)
		if err != nil {
			return nil, errors.Wrap(err, "error creating withdraw instruction")
		}

		tx, err := signer.signTx(ctx, inst, 0)
		if err != nil {
			return nil, errors.Wrap(err, "error signing withdraw instruction")
		}
		return &Outbound{Tx: tx}, nil
	}, nil
}

func (signer *Signer) prepareWithdrawSPLTx(
	ctx context.Context,
	cctx *types.CrossChainTx,
	height uint64,
	logger zerolog.Logger,
) (outboundGetter, error) {
	params := cctx.GetCurrentOutboundParam()
	// compliance check
	cancelTx := compliance.IsCCTXRestricted(cctx)
	if cancelTx {
		compliance.PrintComplianceLog(
			logger,
			signer.Logger().Compliance,
			true,
			signer.Chain().ChainId,
			cctx.Index,
			cctx.InboundParams.Sender,
			params.Receiver,
			"SPL",
		)
	}

	// get mint details to get decimals
	mint, err := signer.decodeMintAccountDetails(ctx, cctx.InboundParams.Asset)
	if err != nil {
		return nil, errors.Wrap(err, "decodeMintAccountDetails error")
	}

	// sign gateway withdraw spl message by TSS
	msg, err := signer.createAndSignMsgWithdrawSPL(
		ctx,
		params,
		height,
		cctx.InboundParams.Asset,
		mint.Decimals,
		cancelTx,
	)
	if err != nil {
		return nil, errors.Wrap(err, "createAndSignMsgWithdrawSPL error")
	}

	return func() (*Outbound, error) {
		// sign the withdraw transaction by relayer key
		inst, err := signer.createWithdrawSPLInstruction(*msg)
		if err != nil {
			return nil, errors.Wrap(err, "error creating withdraw SPL instruction")
		}

		tx, err := signer.signTx(ctx, inst, 0)
		if err != nil {
			return nil, errors.Wrap(err, "error signing withdraw SPL instruction")
		}

		return &Outbound{Tx: tx}, nil
	}, nil
}

As a result, when a withdrawal transaction fails, the nonce in the Solana program remains unchanged.

Internal Pre-conditions

External Pre-conditions

The withdraw method transaction on Solana failed.

Attack Path

Impact

When a withdrawal transaction on Solana fails, the nonce will remain unchanged.

PoC

Mitigation

Ensure withdraw method on node include a increment nonce

The original report as published on Sherlock, by Laksmana. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 withdraw transaction preparation functions omit an instruction to increment the nonce, so a failed withdrawal leaves the nonce unchanged.

Impact

When a withdrawal transaction on Solana fails, the nonce will remain unchanged, potentially causing subsequent withdrawals to fail or be stuck.

What the attacker needed

A withdrawal transaction on Solana fails

The fix

The withdraw method should be updated to include an increment nonce instruction.

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 nonce is a number used once to prevent replay attacks and ensure transactions are processed in order. In this system, the nonce is supposed to increase with each withdrawal, but if a withdrawal fails, the code forgets to increase it, so the nonce stays the same and future withdrawals might be blocked.

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 laksmana

View all

1 more disclosed report, best first.

More from ZetaChain Cross-Chain

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.