Skip to content
Smart contracts Audit finding Intermediate

TotalSupply() overstates circulating VTHO

The TotalSupply() function in the energy module returns the initial grown supply plus cumulative issuance but never subtracts burned amounts, so it overstates the circulating supply. An attacker could not directly steal funds, but downstream contracts relying on totalSupply() may misbehave due to the inflated figure.

spongebob Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

55926 bc insight totalsupply overstates circulating vtho

Submitted on Oct 7th 2025 at 20:42:53 UTC by @spongebob for Attackathon | VeChain Hayabusa Upgrade

Description

energy.TotalSupply() returns the lazily grown base supply plus cumulative issuance and never subtracts burned amounts.

Relevant code:

https://github.com/vechain/thor/blob/3ad5e1805c778a070e27d0d0293f335a256c235e/builtin/energy/energy.go#L108-L134

Go
func (e *Energy) TotalSupply() (*big.Int, error) {
	initialSupply, err := e.getInitialSupply()
	if err != nil {
		return nil, err
	}

	// calc grown energy for total token supply
	acc := state.Account{
		Balance:   initialSupply.Token,
		Energy:    initialSupply.Energy,
		BlockTime: initialSupply.BlockTime,
	}

	// this is a virtual account, use account.CalcEnergy directly
	stopTime, err := e.GetEnergyGrowthStopTime()
	if err != nil {
		return nil, err
	}
	grown := acc.CalcEnergy(e.blockTime, stopTime)

	issued, err := e.getIssued()
	if err != nil {
		return nil, err
	}

	return grown.Add(grown, issued), nil
}

Burns are only tracked by incrementing total.TotalSub inside Energy.Sub (used by gas spending and fees):

https://github.com/vechain/thor/blob/3ad5e1805c778a070e27d0d0293f335a256c235e/builtin/energy/energy.go#L180-L205

https://github.com/vechain/thor/blob/3ad5e1805c778a070e27d0d0293f335a256c235e/runtime/resolved\\_tx.go#L146-L212

The net burned amount is exposed via TotalBurned():

https://github.com/vechain/thor/blob/3ad5e1805c778a070e27d0d0293f335a256c235e/builtin/energy/energy.go#L136-L144

Go
func (e *Energy) TotalBurned() (*big.Int, error) {
	total, err := e.getTotalAddSub()
	if err != nil {
		return nil, err
	}
	burned := new(big.Int).Sub(total.TotalSub, total.TotalAdd)
	return burned, nil
}

Because issued is only increased (for example, block rewards call e.addIssued(reward)) and never decreased, TotalSupply() reports cumulative minted tokens rather than minted minus burned. After any net burn, sum(balanceOf) < totalSupply().

The public ERC‑20 wrapper simply forwards totalSupply() to the native value, so on-chain consumers expecting standard semantics receive the inflated figure unless they manually subtract TotalBurned():

https://github.com/vechain/thor/blob/3ad5e1805c778a070e27d0d0293f335a256c235e/builtin/gen/energy.sol#L25-L27

Solidity
function totalSupply() public view returns(uint256) {
    return EnergyNative(this).native_totalSupply();
}

The native energy module misreports supply, so the network layer exposes incorrect contract data. While nothing is stolen immediately, downstream contracts can misbehave because of the incorrect figure; this is classified as MEDIUM severity.

Proof of Concept (reproduction)

Add the following test to energy_test.go and run.

{% stepper %} {% step %}

Seed an account with energy

Create a state and seed an account with 1 000 VTHO:

Go
st := state.New(muxdb.NewMem(), trie.Root{})

acc := thor.BytesToAddress([]byte("burn"))
if err := st.SetEnergy(acc, big.NewInt(1000), 0); err != nil {
    t.Fatalf("failed to seed energy: %v", err)
}

p := params.New(thor.BytesToAddress([]byte("par")), st)
eng := New(thor.BytesToAddress([]byte("eng")), st, 0, p)

assert.NoError(t, eng.SetInitialSupply(big.NewInt(1), big.NewInt(1000)))

{% endstep %}

{% step %}

Check total supply before burn

Go
totalBefore, err := eng.TotalSupply()
assert.NoError(t, err)
assert.Equal(t, big.NewInt(1000), totalBefore)

{% endstep %}

{% step %}

Burn energy

Go
ok, err := eng.Sub(acc, big.NewInt(600))
assert.NoError(t, err)
assert.True(t, ok)

balance, err := eng.Get(acc)
assert.NoError(t, err)
assert.Equal(t, big.NewInt(400), balance)

{% endstep %}

{% step %}

Observe totalSupply() unchanged while TotalBurned() tracks burns

Go
totalAfter, err := eng.TotalSupply()
assert.NoError(t, err)
assert.Equal(t, totalBefore, totalAfter)
assert.True(t, totalAfter.Cmp(balance) > 0)

burned, err := eng.TotalBurned()
assert.NoError(t, err)
assert.Equal(t, big.NewInt(600), burned)

The test demonstrates that after burning 600 VTHO, TotalSupply() still reports 1 000 while TotalBurned() reports 600 and the account balance is 400, proving the supply overstatement. {% endstep %} {% endstepper %}

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

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

Downstream contracts expecting standard ERC-20 semantics may misbehave because totalSupply() is inflated; no funds are directly at risk.

What the attacker needed

None

The fix

TotalSupply() should subtract the net burned amount (TotalBurned()) from the sum of grown supply and issued tokens.

How it was found

  1. Seed an account with 1000 VTHO and set initial supply.
  2. Check total supply before burn (expect 1000).
  3. Burn 600 VTHO from the account.
  4. Observe totalSupply() unchanged while TotalBurned() reports 600 and balance is 400.

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.

This is a bug in how a blockchain reports the total number of tokens in existence. The code adds up all tokens ever created but forgets to subtract tokens that were destroyed (burned), so the reported total is too high. Other programs that trust this number might make wrong decisions.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by spongebob

View all

15 more disclosed reports, best first.

More from VeChain Hayabusa Upgrade

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.