User can mint more than one tokens per period #1809
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-688
edited-by-warden
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/MinterContract.sol#L249-L252
Vulnerability details
Impact
Users have the option to mint more than one token during a specific period, provided that the previous tokens for that period have not been spent (minted), and the tokens are accumulated.
Consider the scenario in which no one mints tokens for the previous four blocks. The
timePeriod
is 10 seconds, and let's assume each new block is created every 10 seconds.Vulnerability details
The
MinterContract.mint
function is used by users to mint their tokens. If thecollectionPhases[col].salesOption
is set to 3, this will trigger the logic for Periodic Sale (mint), which should limit users to mint only one token during each time period.However, the
lastMintDate[col]
is calculated bygencore.viewCirSupply(col) - 1
multiplied bycollectionPhases[col].timePeriod
, which leads to the problem when one user can mint multiple tokens in one period because the previous period's available tokens are not minted, and they have been accumulated.Proof of Concept
To execute the POC, you will need to utilize the following
Attacker
contract. Place this contract in smart-contracts/Attacker.sol.Next, insert the following test case into test/nextGen.test.js and execute it using the command
hardhat test ./test/nextGen.test.js --grep 'Mint by period'
Tools Used
Manual Review
Recommended Mitigation Steps
Consider setting
lastMintDate
to the current timestamp.Assessed type
Context
The text was updated successfully, but these errors were encountered: