Platform: Code4rena
Start Date: 20/09/2022
Pot Size: $30,000 USDC
Total HM: 12
Participants: 198
Period: 3 days
Judge: 0xean
Total Solo HM: 2
Id: 164
League: ETH
Rank: 198/198
Findings: 1
Award: $0.74
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Czar102
Also found by: 0xDecorativePineapple, 0xNazgul, 0xSky, 0xbepresent, 0xmatt, Atarpara, Bahurum, DimitarDimitrov, Franfran, GimelSec, JGcarv, JLevick, Junnon, OptimismSec, Rolezn, Ruhum, Soosh, Tomo, Trust, __141345__, adriro, ajtra, bin2chen, cRat1st0s, cccz, cryptonue, d3e4, innertia, jag, joestakey, neumo, obront, pashov, pauliax, pcarranzav, peanuts, rajatbeladiya, rbserver, reassor, seyni, wagmi, zzykxx, zzzitron
0.7375 USDC - $0.74
https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/token/VariableSupplyERC20Token.sol#L21 https://github.com/code-423n4/2022-09-vtvl/blob/main/contracts/token/VariableSupplyERC20Token.sol#L40-L44
By definition and comments inside the contract, the VariableSupplyERC20Token.sol will have option to set it as limited supply or unlimited supply. This decision is made on constructor parameter (#L21).
If the token want to be limited supply, then the maxSupply_
need to be set > 0, if it's 0
then it's unlimited supply.
on line #L28, the mintableSupply
is set with this maxSupply_
.
The problem is on the mint()
function, there is a flaw.
The mint function is not respecting the mintableSupply
. On line #43, the mintableSupply
is decreased by mint amount
. This means, at some point, the mintableSupply
can be 0, thus the #L40-#L44 is not being called anymore, so any mint call, will directly _mint()
it.
This mint function can be a potential factor of miscalculation of token supply, affecting Vesting calculation for user, or further usage of this token.
We need to store mintedToken into a state variable, and increment it when minting happen, moreover we should make mintableSupply as immutable, and we use it to check if amount + mintedToken is <= mintableSupply
uint256 mintedToken = 0; function mint(address account, uint256 amount) public onlyAdmin { require(account != address(0), "INVALID_ADDRESS"); if(mintableSupply > 0) { require(amount + mintedToken <= mintableSupply, "INVALID_AMOUNT"); } mintedToken += amount; _mint(account, amount); }
#0 - 0xean
2022-09-24T00:34:16Z
dupe of #3