-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MinterContract.sol#mintAndAuction() reverts due to division by 0 error #1634
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-1980
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Comments
c4-submissions
added
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
labels
Nov 13, 2023
141345 marked the issue as duplicate of #1278 |
141345 marked the issue as duplicate of #962 |
141345 marked the issue as not a duplicate |
141345 marked the issue as duplicate of #1278 |
alex-ppg marked the issue as duplicate of #1980 |
alex-ppg marked the issue as unsatisfactory: |
c4-judge
added
the
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
label
Dec 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-1980
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#L276-L298
Vulnerability details
Bug Description
The
mintAndAuction()
function inMinterContract.sol
has a variabletDiff
that is used to check if a period has passed in order to determine if minting is allowed, MinterContract.sol#L292:If
collectionPhases[_collectionID].timePeriod
is 0, which is highly likely due to this being a requirement for collections with a fixed price sales model, the transaction will revert due to a division by 0 error.Impact
mintAndAuction()
cannot be called on collections that set the_timePeriod
parameter insetCollectionCosts()
to 0 inMinterContract.sol
, notably those with a fixed priced sales model. Projects relying on NextGen’s infrastructure that use a fixed price sales model in conjunction with auctions will be severely limited which may lead to financial loss.Proof of Concept
Alice has 10 pieces of artwork that she would like to sell using NextGen. Her plan is to sell her NFTs using a fixed price sales model and if she does not have success in doing so she will instead put them up for auction using
mintAndAuction()
. She utilizes NextGen to create a collection and following the documentation regarding fixed price sales models, sets the_timePeriod
to 0 when callingsetCollectionCosts()
:When she later calls
mintAndAuction()
the transaction reverts due to a division by 0 error. Here is the Foundry test:forge test --match-path test/foundry/MintAndAuction.t.sol --via-ir -vvvv
Tools Used
Manual Review and Foundry.
Recommended Mitigation Steps
Consider checking if
collectionPhases[_collectionID].timePeriod
is greater than 0 before executing certain logic, MinterContract.sol#L291-L294:Assessed type
Math
The text was updated successfully, but these errors were encountered: