Skip to content
Business logic Audit finding Advanced

Zeta Supply Inflation on Deploy Fungible Gas Coin

Deploying a gas token via the DeployFungibleCoinZRC20 message mints new ZETA tokens without burning them elsewhere, breaking the invariant that total ZETA supply stays constant across chains. An attacker with admin privileges could inflate the ZETA supply, and the process also creates unbacked ZRC20 tokens.

ChristiansWhoHack Follow

Originally disclosed on Code4rena

Submitted by ChristiansWhoHack

The Zetachain whitepaper part 7.3 is titled Comprehensive Defense Against Arbitrary Minting. In this section, there are mentioned security protections that ensure that the supply of Zeta remains the same across all chains. Within the zetaclient, there is even zetasupplychecker.go to ensure that this is the case. According to whitepaper, the total supply should remain the same across all chains with Ethereum being the home supply location. Finding #1 from the Halborn audit puts this as a clear risk as well.

However, this invariant is not always kept. First, the message DeployFungibleCoinZRC20 on a gas token creates a pool within SetupChainGasCoinAndPool. When creating this pool, a call to MintCoins() on the bankkeeper is made. This increases the amount of Zeta without destroying it anywhere, resulting in an inflation of ZETA tokens. This functionality is only callable by admins when new chains are created, but still breaks an important invariant within the system.

Besides increasing the ZETA tokens, it also creates some amount of the ZRC20 token, which may not exist in the TSS at the time. Having funds that are not backed by anything is very dangerous to do.

PoC

To run this PoC, do the following:

  1. Copy the code below into x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go
  2. Add fmt to the list of imports at the top of the file.
  3. Within the node directory of the repo, run the following command: go test -v ./x/fungible/keeper -run TestMsgServer_IncreaseZetaAmount.
  4. Notice that the execution leads to an increase of ‘azeta’ without decreasing it anywhere else. This is shown by the asserts and print statements in the execution of the code.
func TestMsgServer_IncreaseZetaAmount(t *testing.T) {
	t.Run("Deploy token increases zeta amount", func(t *testing.T) {
		k, ctx, sdkk, zk := keepertest.FungibleKeeper(t)
		msgServer := keeper.NewMsgServerImpl(*k)
		k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName)
		admin := sample.AccAddress()
		setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2)
		chainID := getValidChainID(t)

		deploySystemContracts(t, ctx, k, sdkk.EvmKeeper)

		zetaAmountBefore := sdkk.BankKeeper.GetSupply(ctx, "azeta")

		// Deploy a gas token
		_, err := msgServer.DeployFungibleCoinZRC20(ctx, types.NewMsgDeployFungibleCoinZRC20(
			admin,
			sample.EthAddress().Hex(),
			chainID,
			18,
			"ETH",
			"ETH",
			common.CoinType_Gas,
			1000000,
		))
		assert.Equal(t, nil, err) // Call succeeds

		zetaAmountAfter := sdkk.BankKeeper.GetSupply(ctx, "azeta")
		assert.GreaterOrEqual(t, zetaAmountAfter.Amount.Int64(), zetaAmountBefore.Amount.Int64())

        fmt.Println("Supply Zeta Before:", zetaAmountBefore)
        fmt.Println("Supply Zeta After:", zetaAmountAfter)
	})
}

Remediation

To prevent the arbitrary creation of Zeta, funds should be taken from another place. Within the ecosystem, this could be done from any of the other chains, such as Ethereum and others. However, the easiest would be to take the funds from the community pool that lives on Zetachain.

This way, no funds are created out of thin air. This keeps the important invariant that the Zeta supply always stays the same throughout the entire ecosystem.

lumtis (ZetaChain) confirmed


The original report as published on Code4rena, by ChristiansWhoHack. 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

Impact

The ZETA supply could be inflated, and unbacked ZRC20 tokens could be created, though the function is only callable by admins when new chains are created.

What the attacker needed

Admin privileges; new chain creation

The fix

Funds should be taken from another place, such as the community pool on ZetaChain, instead of minting new ZETA.

How it was found

  1. Copy the provided test code into the fungible keeper test file.
  2. Add the fmt import to the test file.
  3. Run the specific Go test for the deploy fungible coin message.
  4. Observe that the azeta supply increases without any decrease elsewhere.

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.

ZETA is a cryptocurrency token, and the system is designed so that the total number of tokens stays the same across all blockchains. This report shows that when an admin sets up a new gas token for a chain, the system creates extra ZETA out of thin air instead of moving existing tokens. That breaks the promise that no new ZETA can be made arbitrarily.

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 ChristiansWhoHack

View all

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