setFinalSupply
can set totalSupply of a non-existent collection
#1997
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-c
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/NextGenCore.sol#L307-L311
Vulnerability details
Description
setFinalSupply
allows setting thecollectionTotalSupply
of a non-existent_collectionId
. If that happens,setCollectionData
can't set the booleanwereDataAdded[_collectionId]
for a collection, which makes several critical functions that checks that boolean to be forever not callable in the collection.Proof of Concept
setFinalSupply
for a non-existent_collectionId
:It requires that
block.timestamp > collectionPhases[_collectionID].publicEndTime + collectionAdditionalData[_collectionID].setFinalSupplyTimeAfterMint
. For a non-existent_collectionId
, these values are zero as default, so the check is effectivelyblock.timestamp > 0
, which is always true._collectionId
will be used,setCollectionData
is called to set collection's importants metadatas. However, the only path to setwereDataAdded[_collectionId] = true
is ifcollectionTotalSupply
is zero:wereDataAdded[_collectionId]
, including the one that sets minting price, are forever not callable for that_collectionId
. They're critical, so the collection_collectionId
is not usable anymore. Here are some of the functions (setCollectionCosts
,airDropTokens
,mintAndAuction
):setCollectionCosts
also makes impossible to callmint
, since it needs a price for the collection.Impact
Makes a
_collectionId
not usable, which takes time from the team to debug the mistake, to recreate the collection if some data was already set and wrongly account the number of_collectionId
.Tools Used
Manual Review
Recommended Mitigation Steps
setFinalSupply
needs to check ifwereDataAdded[_collectionId] == true
or if collection exists.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: