Skip to content
Business logic Audit finding Advanced

Incorrect amount of zrc20 approved in GatewayTransferNative causing loss of fund and DOS

The contract approved more tokens than needed to the gateway, leaving a residual allowance. An attacker could use that allowance to make the contract pay gas fees, causing fund loss and potentially blocking refunds.

Cybrid Follow with EgisSecurity, Phaethon and 6 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-05-dodo-cross-chain-dex-judging/issues/230

Found by

Cybrid, EgisSecurity, Phaethon, bladeee, farismaulana, hunt1, m3dython, newspacexyz, rsam_eth

Summary

In GatewayTransferNative.sol::_handleEvmOrSolanaWithdraw(), the contract approved outputAmount+gasFee tokens to GatewayZEVM but the GatewayZEVM will only use outputAmount tokens. Attackers could make use of this extra approved gasFee to attack the contract using the public function GatewayTransferNative::withdraw().

Root Cause

https://github.com/sherlock-audit/2025-05-dodo-cross-chain-dex/blob/main/omni-chain-contracts/contracts/GatewayCrossChain.sol#L379C5-L440C6

When users want to withdraw tokens from zetachain to an evm chain, the function above will be called. For simplicity, let's consider that user wants to withdraw ETH to Ethereum from zetachain.

He calls withdrawToNativeChain(ETH,1000e18,message). The _handleFeeTransfer() function will take 1000 ether from user and send 0.5% to TreasurySafe. Now outputAmount=amount=995ether, and then _handleEvmOrSolanaWithdraw() is called. In this function, GatewayTransferNative approve GatewayZEVM for outputAmount+gasFee ETH but it set amountsOutTarget to outputAmount-gasFee. Finally in GatewayZEVM contract, only outputAmount-gasFee ETH and gasFee ETH for gasfee is charged.

After the transaction, there are still gasFee amount of ETH in allowance of GatewayTransferNative to GatewayZEVM. If now GatewayTransferNative has a positive ETH balance (for example, in refunds) , it's possible for attackers to spend gasFee amount of ETH and the contract lose money.

Internal Pre-conditions

GatewayTransferNative has a positive balance of gas tokens

External Pre-conditions

gasprice decreases sometimes

Attack Path

Suppose GatewayTransferNative has an ETH balance waiting for refunding and someone has withdrawn ETH from zetachain to Ethereum. As explained in the root cause, now ETH.allowance(GatewayTransferNative,GatewayZEVM) is gasFee. Notice that gasFee is calculated by gasPrice*gasLimit where gasLimit is fixed. 1.When gasPrice decreases to gasPrice1 , Alice set amount=(gasPrice-gasPrice1)*gasLimit. 2.Alice call GatewayTransferNative::withdraw() with outputToken:ETH and amount above. 3. GatewayZEVM will charge GatewayTransferNative for gasFee1=gasPrice1*gasLimitETH and amount=(gasPrice-gasPrice1)*gasLimitETH 4. In total the previous allowance is consumed to 0 now.

The cost of the attacker: some gas fee in ZETA, worth nothing(ZETA price $0.2 now ,negligible) The GatewayTransferNative lose: gasFee in ETH (ETH price $2491)

Impact

The GatewayTransferNative contract could suffer a loss of gasFee after every cross-chain call. Right now the gasFee is only a small value of USD even on Ethereum mainnet, but in the future, as the gas price goes up and more and more transactions passing through the contract, it could be a non-negligible number. Even worse, after losing the gasFee, GatewayTransferNative contract doesn't have enough balance to pay the refunds which leads to DOS for a honest users claiming their refund.

PoC

No response

Mitigation

No response

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/Skyewwww/omni-chain-contracts/pull/34

The original report as published on Sherlock, by Cybrid. 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 contract approved an amount that included gasFee, but the gateway only used outputAmount, leaving a residual allowance.

What the attacker needed

GatewayTransferNative has positive gas token balance; Gas price decreases

The fix

The contract should approve only the exact amount needed, not including the gas fee.

How it was found

  1. Ensure GatewayTransferNative has a positive balance of gas tokens.
  2. Wait for a user to withdraw tokens, creating a residual allowance.
  3. When gas price decreases, calculate the difference in gas cost.
  4. Call withdraw() with an amount equal to that difference.
  5. The gateway charges the contract for gas and the amount, consuming the allowance.

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 you approve someone to spend your tokens, they can take up to that amount. Here the contract approved more than necessary, leaving extra spending permission. An attacker can use that leftover permission to make the contract pay for gas, draining its funds.

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 Cybrid

View all

3 more disclosed reports, best first.

More from DODO Cross-Chain DEX

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.