Skip to content
Business logic Audit finding Intermediate

Gas Coin Setup Result In Immediate Profitable Arbitrage

When a new gas coin is added, the protocol automatically creates a liquidity pool with a fixed 0.1 amount of the gas token and 0.1 WZETA, which can be highly imbalanced for valuable tokens like BTC. An attacker could monitor for new chain support and backrun the liquidity addition to swap ZETA for the gas token at a favourable rate, making an instant profit at the protocol's expense.

MevSec Follow

Originally disclosed on Code4rena

Submitted by MevSec

A gas coin can be added by running the DeployFungibleCoinZRC20 message. This is most notably done when adding a new blockchain support, because each of them has their respective supported “gas ZRC20” which is the native token of this newly supported blockchain as a ZRC compliant token on Zetachain. These liquidity pools are required because we need to be able to get those “gas ZRC20” at some point in order to burn them to redeem them for an equivalent amount of native tokens.

If this new blockchain that is supported is Polygon, then we will deploy a liquidity pool with 0.1 WZETA and 0.1 zrc20-MATIC on deployment so validators can swap these ZETA tokens for the Polygon’s native token.

From the code:

// If this is a gas coin, the following happens:
//
// * ZRC20 contract for the coin is deployed
// * contract address of ZRC20 is set as a token address in the system
// contract
// * ZETA tokens are minted and deposited into the module account
// * setGasZetaPool is called on the system contract to add the information
// about the pool to the system contract
// * addLiquidityETH is called to add liquidity to the pool

Which calls the SetupChainGasCoinAndPool function.

This is not an issue for low value tokens, but is for tokens such as BTC, ETH, and SOL. If we take the example of BTC, with 0.1 BTC having a value of ~4400$ being added with a ZETA token which is going to make the pool imbalanced with a significant value at stake.

An arbitrage opportunity will be created as a first come first serve rule, which is going to be a net loss for the protocol because these “gas ZRC20” can be directly redeemed for native tokens on the blockchain by users by withdrawing the assets later.

Someone could then monitor for new blockchains supported by Zetachain and if the token valuation is extremely disparate compared to the ZETA token, they could backrun the liquidity add by swapping some ZETA tokens and make an instant profit.

In this command, we ask for the token0 name of the pair 0 which is the ETH ZRC20 gas token:

$ cast call $(cast call $(cast call 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c "allPairs(uint256)(address)" 0) "token0()(address)") "name()(string)"
"ETH-goerli_localnet"

And we can also verify that the balance of each assets in the reserves is 0.1:

$ cast call $(cast call 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c "allPairs(uint256)(address)" 0) "getReserves()(uint112,uint112,uint32)"
100000000000000000 [1e17]
100000000000000000 [1e17]
1702765357 [1.702e9]

Next, let’s check for BTC:

$ cast call $(cast call $(cast call 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c "allPairs(uint256)(address)" 1) "token1()(address)") "name()(string)"
"BTC-btc_regtest"

Make sure that 0.1 BTC is in the reserves:

$ cast call $(cast call 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c "allPairs(uint256)(address)" 1) "getReserves()(uint112,uint112,uint32)"
100000000000000000 [1e17]
10000000 [1e7]
1702765357 [1.702e9]

Recommended Mitigation Steps

Before adding a new blockchain and a gas token, you could either add much less initial liquidity such as a mantissa of -3 to make the BTC amount much less profitable, or make the initial liquidity configurable from the message passing.

lumtis (ZetaChain) confirmed

0xean (Judge) decreased severity to Medium


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

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 fixed initial liquidity amount (0.1 of each asset) does not account for the real-world value of the gas token, creating an arbitrage opportunity.

Impact

An attacker could make an instant profit at the protocol's expense, causing a net loss for the protocol, especially for high-value tokens like BTC, ETH, and SOL.

What the attacker needed

New blockchain support added; attacker monitors new chain additions; attacker can backrun transaction

The fix

The initial liquidity should be made much smaller (e.g., a mantissa of -3) or made configurable via the message passing.

How it was found

  1. Deploy a new gas coin via the DeployFungibleCoinZRC20 message, which calls SetupChainGasCoinAndPool.
  2. The function adds liquidity with 0.1 of the gas token and 0.1 WZETA.
  3. An attacker monitors for new blockchains and checks if the token valuation is disparate.
  4. The attacker backruns the liquidity addition by swapping ZETA tokens for the gas token.
  5. The attacker redeems the gas token for native tokens, making a profit.

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 new blockchain is added, the system automatically creates a trading pool with a fixed amount of the new chain's gas token and its own token. If the gas token is valuable (like Bitcoin), the pool starts with a very unfair exchange rate. Someone can quickly trade the system's token for the valuable gas token and sell it for a profit, draining value from the system.

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 MevSec

View all

1 more disclosed report, best first.

More from ZetaChain

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.