Incorrect computation allows cheaper mints in periodic sale #266
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-641
sufficient quality report
This report is of sufficient quality
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#L536
Vulnerability details
Impact
The idea behind the third sale model, periodic sale, is that for each new minted NFT, the price increases with a given % of the initial price. This % is the _rate parameter in the MinterContract.setCollectionCosts() function. MinterContract.getPrice() calculates the price incorrectly. Let's have a look:
It divides the initial mint cost by the rate. So if the rate is 20%, the new price will become initialPrice / 20, which is actually 5% increase and not 20%. This lets users mint NFTs for significantly less money.
Proof of Concept
Let's look at the following case:
As a result we have minted 5 NFTs for 5.5 ETH, not for 7 ETH. Here is a PoC in Foundry:
Proof of Concept
Tools Used
Foundry
Recommended Mitigation Steps
Instead of dividing the mint cost by rate, multiply it by rate and then divide by 100.
Assessed type
Math
The text was updated successfully, but these errors were encountered: