User not refunded for failed Zeta gas payment in cross chain transaction
When a cross-chain transaction on ZetaChain fails during processing, the code marks it as aborted but only attempts a refund for ERC20 inbound transactions, and for cross-chain swaps no refund logic exists at all. This can leave user funds temporarily or permanently frozen, depending on whether TSS holders manually intervene.
Submitted by deliriusz, also found by oakcobalt, zhaojie, and dontonka
Vulnerability details
When observed CCTX (cross chain transaction) gathers enough votes in VoteOnObservedInboundTx, it is being processed immediately. In case that the transaction is reverted for whatever reason, it returns an error and changes CCTX status to CctxStatus_Aborted - such a transaction won’t be processed:
if err != nil {
// do not commit anything here as the CCTX should be aborted
// gas payment for erc20 type might fail because no liquidity pool is defined to swap the zrc20 token into the gas token
// in this gas we should refund the sender on ZetaChain
if cctx.InboundTxParams.CoinType == common.CoinType_ERC20 {
if err := k.RefundAmountOnZetaChain(ctx, cctx, cctx.InboundTxParams.Amount); err != nil {
// log the error
k.Logger(ctx).Error("failed to refund amount of aborted cctx on ZetaChain",
"error", err,
"sender", cctx.InboundTxParams.Sender,
"amount", cctx.InboundTxParams.Amount.String(),
)
}
}
cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, err.Error())
return &types.MsgVoteOnObservedInboundTxResponse{}, nil
There is also no mechanism for retrieving the funds back. TSS could probably initialize such a refund, however it required quorum of nodes to do so, and there is no automatic process for this in code in scope. Possible issues for transaction errors are numerous, I’ll list just some of them that immediately come to my head:
- too little amount to cover gas fees. Please note that UniswapV2 is used here, and as described in another issue, it doesn’t have proper price manipulation protection, meaning that one of the results may be swapping in highly manipulated pool for overly small fee token amount, making the CCTX error out and abort
- no valid pool for UniswapV2 swap
- too little gas paid to process the transaction
- stale gas prices recorded by keepers
- any issues with gas coin setting in the zetacored
For cross chain swaps it’s even worse, because there is no notion of a refund at all, meaning that the funds are frozen:
// [...]
} else { // Cross Chain SWAP
tmpCtx, commit := ctx.CacheContext()
err = func() error {
err := k.PayGasAndUpdateCctx(
tmpCtx,
receiverChain.ChainId,
&cctx,
cctx.InboundTxParams.Amount,
false,
)
if err != nil {
return err
}
// [...]
}()
if err != nil {
// do not commit anything here as the CCTX should be aborted
cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, err.Error()) // @audit status changed to "Aborted" without refunding user the money. This refund is partially handled in case of transaction to Zeta
return &types.MsgVoteOnObservedInboundTxResponse{}, nil
}
Impact
Temporary or permament freezing of user funds, depending if TSS holders technically are able and willing to refund the funds manually.
Proof of Concept
- User creates cross chain transaction in ZetaChain
- The tranasction is reverted, due to Uniswap pool imbalance. Because EVM returns error, the transaction status is changed to
Aborted. - The user funds are locked.
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 error-handling path for aborted cross-chain transactions only refunds ERC20 inbound transfers and omits any refund for cross-chain swaps, leaving funds locked.
What the attacker needed
Cross-chain transaction on ZetaChain; transaction fails during processing
How it was found
- User creates cross chain transaction in ZetaChain
- The transaction is reverted, due to Uniswap pool imbalance, and its status is changed to Aborted
- The user funds are locked
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 transaction moves funds from one blockchain to another. If something goes wrong during processing, the system should return the money to the sender. Here, for some transaction types, it does not, so the money can get stuck.
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.