FestivalPass.redeemMemorabilia()
Prevents Last NFT from Being MintedThe FestivalPass.redeemMemorabilia()
function is used by the users to mint an nft inside a memorabilia collection.
However the FestivalPass.redeemMemorabilia()
function contains an off-by-one error in its supply check. The function uses a strict less-than comparison (<
) to check if the currentItemId
is less than the maxSupply
.
Because currentItemId
represents the ID of the next token to be minted, its value reaches maxSupply
when maxSupply - 1
tokens have already been minted. At this point, the check collection.currentItemId < collection.maxSupply
(which evaluates to maxSupply < maxSupply
) fails, making it impossible to mint the final memorabilia item.
Likelihood:
This issue occurs when the number of memorabilia redeemed has reached maxSupply - 1
of that collection.
Impact:
The issue prevents all memorabilia collections from ever being fully sold out, causing users to not be able to redeem when they should be able to.
Append the following poc to FestivalPass.t.sol
and run it using forge test --mt test_RedeemMemorabilia_CantRedeemLastMemorabilia
The strict less-than check (<
) should be changed to a less-than-or-equal-to check (<=
) to allow the currentItemId
to equal maxSupply
during the final mint. This ensures all items up to and including the one with the ID maxSupply
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.