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.
- 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
- Report ID: #55926
- Report Type: Blockchain/DLT
- Report severity: Insight
- Target: https://github.com/vechain/thor/compare/master...release/hayabusa
- Impacts:
- A bug in the respective layer 0/1/2 network code that results in unintended smart contract behavior with no concrete funds at direct risk
Description
energy.TotalSupply() returns the lazily grown base supply plus cumulative issuance and never subtracts burned amounts.
Relevant code:
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):
The net burned amount is exposed via TotalBurned():
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():
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:
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
totalBefore, err := eng.TotalSupply()
assert.NoError(t, err)
assert.Equal(t, big.NewInt(1000), totalBefore)
{% endstep %}
{% step %}
Burn energy
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
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 %}
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
- Seed an account with 1000 VTHO and set initial supply.
- Check total supply before burn (expect 1000).
- Burn 600 VTHO from the account.
- 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.