Skip to content
Business logic Audit finding Intermediate

Wrong postGasPrice() implementation can lead to loss of funds

The Sui observer's PostGasPrice function stored the gas price in memory before successfully posting and validating it via PostVoteGasPrice. If the vote failed, the stale gas price could be used in VoteOutbound, causing the validator to vote with unagreed parameters and potentially face slashing and fund loss.

0x73696d616f Follow with BrothersInCode

Originally disclosed on Sherlock

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

Found by

0x73696d616f, BrothersInCode

Description

In Sui’s implementation, the gas price is committed to memory before posting it and before running validation on the gas price.

Before showing the code of Sui’s implementation, it will make more sense if we look at the implementation of Ton, which is the correct way of implementing it.

In ton/observer/observer.go::PostGasPrice() : https://github.com/zeta-chain/node/blob/835341df556faefeb450770cceb6f959be4f32cc/zetaclient/chains/ton/observer/observer.go#L75

Go
func (ob *Observer) PostGasPrice(ctx context.Context) error {
//.. ommitted code
	_, err = ob.ZetacoreClient().PostVoteGasPrice(ctx, ob.Chain(), gasPrice, priorityFee, blockNum)
	if err != nil {
		return errors.Wrap(err, "failed to post gas price")
	}

	ob.setLatestGasPrice(gasPrice)
//.. ommitted code
}

We can see that the gas price is first validated and voted on in PostVoteGasPrice() . If an error occurs in PostVoteGasPrice(), the function returns.

If it does not error, gasPrice will be set in memory using ob.setLatestGasPrice()

This is the correct way of implementing it.

Now, let’s take a look at Sui’s implementation. If we take a look at sui/observer/observer.go::PostGasPrice() :

Go
func (ob *Observer) PostGasPrice(ctx context.Context) error {
//.. ommitted code
	ob.setLatestGasPrice(gasPrice)

	_, err = ob.ZetacoreClient().PostVoteGasPrice(ctx, ob.Chain(), gasPrice, priorityFee, epochNum)
	if err != nil {
		return errors.Wrap(err, "unable to post vote for gas price")
	}
//.. ommitted code
}

As we can see, the gasPrice is set in memory before PostVoteGasPrice(). This means that when PostVoteGasPrice() fails, the memory will be pointing to an invalid gasPrice.

This invalid gasPrice will be used in Sui’s implementationVoteOutbound:

Go

func (ob *Observer) VoteOutbound(ctx context.Context, cctx *cctypes.CrossChainTx) error {
//.. ommitted code
	outboundGasPrice := math.NewInt(int64(ob.getLatestGasPrice()))
//.. ommitted code
}

As such, outbound votes can be made with invalid gas parameters, leading to the honest validator performing slashable behavior which in turns can lead to loss of funds.

Proof of Concept

  • Alice calls the periodic PostGasPrice() function.
  • Alice sets the current_gas_price to X
  • When passing X to PostVoteGasPrice(), it errors and does not post the gas price, returning the PostGrasPrice()
  • However, the current_gas_price is set to X , which has not been voted on by other observers.
  • Alice will use this gas price in VoteOutbound , which leads to slashable behavior since these are parameters not voted on, which can lead to funds lost.
  • Furthermore, this can lead undefined behavior depending on the gas price used. Issues like these trickle down and can impact other facets of the zetaclient node.
  • The gas price must match across the active observer set for the vote to count toward consensus. This is why gas prices are pre-agreed upon through MsgVoteGasPrice so when observers report the outbound, they’re all expected to use the same gas price, ensuring determinism in fee logic, swaps, and minting.

Recommendation

Only set the gas price after it has been posted & validated, just like done on the Ton implementation.

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/zeta-chain/node/pull/3967

gjaldon

The gas price is set only after voting on the gas price to fix the issue.

The original report as published on Sherlock, by 0x73696d616f. 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

The gas price was stored in memory before the vote to agree on it succeeded, so a failed vote left an unvalidated price in use.

Impact

Outbound votes could be made with invalid gas parameters, leading to slashable behaviour and potential loss of funds, and may cause undefined behaviour depending on the gas price used.

What the attacker needed

Validator runs Sui observer; PostVoteGasPrice fails

The fix

The gas price should only be set after it has been posted and validated, as done in the Ton implementation; the protocol team fixed this issue.

How it was found

  1. Alice calls the periodic PostGasPrice function.
  2. Alice sets the current_gas_price to X.
  3. When passing X to PostVoteGasPrice, it errors and does not post the gas price, returning from PostGasPrice.
  4. However, the current_gas_price is set to X, which has not been voted on by other observers.
  5. Alice will use this gas price in VoteOutbound, which leads to slashable behavior.

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.

In a blockchain system, validators must agree on the gas price before using it to process transactions. This report shows that one part of the code saved a new gas price too early, even if the step to share and agree on it failed. That could make the validator act on a price others did not approve, which might get it punished and lose money.

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 0x73696d616f

View all

172 more disclosed reports, 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.