Open howlbot-integration[bot] opened 3 months ago
koolexcrypto changed the severity to 2 (Med Risk)
koolexcrypto marked the issue as not a duplicate
koolexcrypto marked the issue as primary issue
koolexcrypto marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2024-07-traitforge/blob/279b2887e3d38bc219a05d332cbcb0655b2dc644/contracts/TraitForgeNft/TraitForgeNft.sol#L202-L225
Vulnerability details
Impact
The mintWithBudget function uses a dynamic pricing mechanism without implementing slippage protection. Given the specific pricing parameters, this can lead to users paying more than anticipated for their NFTs, especially for larger mints or mints occurring later in a generation. Specific impacts include:
Proof of Concept
The current implementation calculates the mint price for each NFT individually within the minting loop:
Consider the following scenario:
User calculates that they can mint 100 NFTs with a budget of 12.75 ETH when 5000 NFTs have been minted in the current generation.
They can now only mint 99 NFTs (12.75 / 0.128725 ≈ 99.04) Total cost for 99 NFTs: approximately 12.74 ETH Remaining 0.01 ETH is refunded
Actual outcome:
User receives 99 NFTs instead of the expected 100 The average price paid per NFT is higher than initially calculated
This scenario demonstrates how the lack of slippage protection in the dynamic pricing mechanism can lead to users receiving fewer NFTs than they anticipated or paying more per NFT than expected, due to price increases caused by other users' minting activities between the time of calculation and the transaction being processed.
Tools Used
manual view
Recommended Mitigation Steps
add slippage protection
Assessed type
Context