Skip to content
Business logic Audit finding Intermediate

Supply cap of VariableSupplyERC20Token is not properly enforced

The token contract treats a remaining mintable supply of zero as unlimited, so once the admin mints the entire capped supply, the cap is no longer enforced and any number of additional tokens can be minted. An attacker with admin privileges could therefore inflate the token supply beyond the intended maximum.

Czar102 Follow

Originally disclosed on Code4rena

Submitted by Czar102, also found by 141345, 0xbepresent, 0xDecorativePineapple, 0xmatt, 0xNazgul, 0xSky, adriro, ajtra, Atarpara, Bahurum, bin2chen, cccz, cRat1st0s, cryptonue, d3e4, DimitarDimitrov, Franfran, GimelSec, innertia, jag, JGcarv, JLevick, joestakey, Junnon, neumo, obront, OptimismSec, pashov, pauliax, pcarranzav, peanuts, rajatbeladiya, rbserver, reassor, Rolezn, Ruhum, seyni, Soosh, Tomo, Trust, wagmi, zzykxx, and zzzitron

VariableSupplyERC20Token.sol#L36-L46

The admin of the token is not constrained to minting maxSupply_, they can mint any number of tokens.

Proof of Concept

// If we're using maxSupply, we need to make sure we respect it
// mintableSupply = 0 means mint at will
if(mintableSupply > 0) {
	require(amount <= mintableSupply, "INVALID_AMOUNT");
	// We need to reduce the amount only if we're using the limit, if not just leave it be
	mintableSupply -= amount;
}

The logic is as follows: if the amount that can be minted is zero, treat this as an infinite mint. Else require that the minted amount is not larger than mintable supply.

One can note that it is possible to mint all mintable supply. Then the mintable supply will be 0 which will be interpreted as infinity and any number of tokens will be possible to be minted.

Recommended Mitigation Steps

Treat 2 ** 256 - 1 as infinity instead of 0.

0xean (judge) decreased severity to Medium and commented:

The warden’s logic is correct, but given that this is behind an admin only flag, there are some external factors that would need to come into play for this to be realized. Downgrading to Medium severity.

lawrencehui (VTVL) confirmed


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

The contract uses a mintable supply of zero as a sentinel for unlimited minting, but the same value is reached when the capped supply is fully minted, so the cap is bypassed.

Impact

The supply cap is not enforced, so an admin could mint unlimited tokens, diluting holders; the judge noted this requires admin-only access and downgraded severity to Medium.

What the attacker needed

Admin privileges on the token

The fix

The contract should treat a very large number (such as 2**256 - 1) as the unlimited sentinel instead of zero.

How it was found

  1. The admin mints tokens until the mintable supply reaches zero.
  2. The contract now interprets zero as unlimited minting.
  3. The admin can mint any number of additional tokens beyond the intended cap.

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.

A token contract has a maximum number of tokens that can ever be created. The code uses zero to mean 'no limit', but it also uses zero to mean 'the limit has been reached'. So after the admin creates the last allowed token, the contract thinks there is no limit and lets the admin keep creating more.

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 Czar102

View all

12 more disclosed reports, best first.

More from VTVL contest

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.