Normally, the redeemMemorabilia
function should allow users to mint up to the full maxSupply
of memorabilia items in a collection.
In this implementation, the function checks require(collection.currentItemId < collection.maxSupply, "Collection sold out")
. Since currentItemId
starts at 1 and is incremented after minting, this check prevents minting the final item, so only maxSupply - 1
items can ever be minted.
Likelihood:
This will occur every time a memorabilia collection is created and users attempt to mint up to the maximum supply.
Any collection with a nonzero max supply will be affected, so the issue is present in all normal usage.
Impact:
Users will be unable to mint the final item in each collection, resulting in fewer NFTs than intended.
This can lead to user confusion, failed transactions, and failure to meet advertised collection goals.
To reproduce this issue, copy and paste the following test code into your test file (e.g., test/contract.t.sol
). This test creates a collection with a max supply of 3, but only 2 items can be minted before the function reverts:
Explanation:
This test shows that, despite a max supply of 3, only 2 items can be minted. The third attempt reverts with "Collection sold out", proving the off-by-one error.
Change the strict inequality (<
) to a non-strict inequality (<=
) so the final item can be minted.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.