Protocol fee is stuck in the `crosschain` module
The protocol fee is added to the Zeta amount minted for a gas payment, but only the swap amount is used, leaving the fee stuck in the crosschain module. Over time, these fees accumulate with no way to retrieve them, causing a loss to the protocol.
Audinarey Follow with Flashloan44
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-04-zetachain-cross-chain-judging/issues/280
Found by
Audinarey, Flashloan44
Summary
When PayGasInZetaAndUpdateCctx() is called, the Zeta amount is swapped for gasZRC20 and the protocolfees are added to this amount to determine the amount of Zeta tokens to mint to the crosschain module. However after the swap the protocol fees are left in the crosschain module.
Root Cause
As shown below, the feeInZeta is the sum of the protocol fees and the amount of zeta nedeed for the swap to gasZRC20 which in turn is burned on L428 below,
The feeInZeta is minted on L399 to cover swapping and protocol fees, however after the swap, the protocol fee is left in the crosschain module and there is no way to retrieve it as there is no function to do this causing the fees accrued over time to be stuck in the module.
The only withdrawal that is implemented if WithdrawFromGasStabilityPool()
File: node/x/crosschain/keeper/gas_payment.go
317: func (k Keeper) PayGasInZetaAndUpdateCctx(
318: ctx sdk.Context,
319: chainID int64,
320: cctx *types.CrossChainTx,
321: zetaBurnt sdkmath.Uint,
322: noEthereumTxEvent bool,
323: ) error {
////SNIP
374: // get the gas fee in Zeta using system uniswapv2 pool wzeta/gasZRC20 and adding the protocol fee
375: outTxGasFeeInZeta, err := k.fungibleKeeper.QueryUniswapV2RouterGetZetaAmountsIn(ctx, outTxGasFee.BigInt(), gasZRC20)
376: if err != nil {
377: return cosmoserrors.Wrap(err, "PayGasInZetaAndUpdateCctx: unable to QueryUniswapV2RouterGetZetaAmountsIn")
378: }
379: @> feeInZeta := types.GetProtocolFee().Add(sdkmath.NewUintFromBigInt(outTxGasFeeInZeta))
////SNIP
398: {
399: @> coins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, sdkmath.NewIntFromBigInt(feeInZeta.BigInt()))) // amount iof zeta actualy needed for this tx
400: err := k.bankKeeper.MintCoins(ctx, types.ModuleName, coins)
401: if err != nil {
402: return cosmoserrors.Wrap(err, "PayGasInZetaAndUpdateCctx: unable to mint coins")
403: }
404:
405: @> amounts, err := k.fungibleKeeper.CallUniswapV2RouterSwapExactETHForToken(
406: ctx,
407: types.ModuleAddressEVM,
408: types.ModuleAddressEVM,
409: outTxGasFeeInZeta,
410: gasZRC20,
411: noEthereumTxEvent,
412: )
413: if err != nil {
414: return cosmoserrors.Wrap(
415: err,
416: "PayGasInZetaAndUpdateCctx: unable to CallUniswapv2RouterSwapExactETHForToken",
417: )
418: }
419:
420: ctx.Logger().Info("gas fee", "outTxGasFee", outTxGasFee, "outTxGasFeeInZeta", outTxGasFeeInZeta)
421: ctx.Logger().Info("CallUniswapv2RouterSwapExactETHForToken",
422: "zetaAmountIn", amounts[0],
423: "zrc20AmountOut", amounts[1],
424: )
425:
426: // FIXME: investigate small mismatches between amounts[1] and outTxGasFee
427: // https://github.com/zeta-chain/node/issues/1303
428: @> err = k.fungibleKeeper.CallZRC20Burn(ctx, types.ModuleAddressEVM, gasZRC20, amounts[1], noEthereumTxEvent)
As shown below, the protocol fee is 2e18
File: node/x/crosschain/types/keys.go
26: @> ProtocolFee = 2000000000000000000
///SNIP
32:
33: func GetProtocolFee() math.Uint {
34: return math.NewUint(ProtocolFee)
35: }
Internal Pre-conditions
NIL
External Pre-conditions
NIL
Attack Path
This does not need an attack path as it is a logic flaw explained in the root cause section
Impact
This leads to funds getting stuck in the module leading to a loss for the protocol
PoC
No response
Mitigation
Consider implementing a function for the protocol fees to be retrieved from the crosschain module or better still transfer it to the protocl address in the execution flow still
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/zeta-chain/node/pull/3734
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 code mints an amount that includes the protocol fee but only swaps the gas fee portion, leaving the fee in the module with no withdrawal function.
Impact
Protocol fees accumulate in the crosschain module and are permanently stuck, causing a loss to the protocol.
What the attacker needed
None
The fix
The protocol team fixed this issue in a pull request.
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.
When a user pays gas in Zeta, the system mints some extra Zeta to cover both the swap for gas and a protocol fee. But the code only uses the swap portion, so the fee portion stays in the module's account and cannot be withdrawn. This means the protocol loses those fees permanently.
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.