Closed c4-submissions closed 11 months ago
141345 marked the issue as duplicate of #246
alex-ppg marked the issue as not a duplicate
alex-ppg marked the issue as duplicate of #2012
alex-ppg changed the severity to 3 (High Risk)
alex-ppg marked the issue as partial-50
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L239-L253 https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L181-L192
Vulnerability details
Impact
The
mint
function contains a control mechanism for sell option 3, ensuring that only one token can be minted per period.If
lastMintDate[col] == 0
(misinterpreted as indicating no tokens have been minted), thetimeOfLastMint
is calculated ascollectionPhases[col].allowlistStartTime - collectionPhases[col].timePeriod
, overlookingviewCirSupply
- the number of minted tokens.At the same time, the value of
viewCirSupply
may not be zero if there was an airdrop before. This is because theairDropTokens
function mints the token but doesn't setlastMintDate
.The subsequent assignment of the
lastMintDate
takes into account theviewCirSupply
:Thus, if there was an airdrop, then one token can be minted after the sales phase started anyway, but the next mint is only possible after
timePeriod
multiplied by the number of airdropped tokens.Depending on the design, there may be different expectations regarding how it should work correctly, but one of the considered cases is not valid.
Proof of Concept
Let's look at an example:
viewCirSupply
= 30)allowlistStartTime
= 1700000000timePeriod
= 86400 (1 day)block.timestamp
= 1700000000First
mint
call after the sales phase starts:lastMintDate
== 0timeOfLastMint
= 1700000000 - 86400 = 1699913600lastMintDate
= 1700000000 + (86400 * (31 - 1)) = 1702592000 (in 30 days)Second
mint
call:lastMintDate
== 1702592000timeOfLastMint
= 1700000000 - 1702592000 = -2592000 (underflow, call reverts)mint
function will revert for the next 30 days)Tools Used
Manual review
Recommended Mitigation Steps
Depending on the intended design:
timeOfLastMint
, consider the currentviewCirSupply
, preventing unintended mints during the sale phase.lastMintDate
. This prevents airdrops from affecting the next allowed minting time.Assessed type
Other