Address 0x0000000000000000000000000000000000000000 can be selected as Ram
The problem relies on the conditions of tokenIds in the ChoosingRam::IncreaseincreaseValuesOfParticipants
where we check if the two arguments are striclty greater than ramNFT.tokenCounter()
However the incrementation in RamNFT::mintRamNFT
is done using uint256 newTokenId = tokenCounter++;
the post-increment operator (tokenCounter++) returns the current value of tokenCounter before incrementing it. Therefore, if tokenCounter is initially 0, newTokenId will also be 0 before tokenCounter is incremented. and this means that at anytime the nft with tokenID tokenCounter isn't minted yet and not assigned to anyone.
An attacker or an ignorant user could spam ChoosingRam::IncreaseincreaseValuesOfParticipants
. with tokenIdOfAnyPerticipent
equal to tokenCounter
. This could result in the NFT associated with tokenCounter (which is unminted and thus assigned to the zero address) being selected as NFT of the Ram. Consequently, the protocol would be broken as half of the funds would not go to any participant but remain unassigned.
Foundry
Ensure that the checks in ChoosingRam::increaseValuesOfParticipants validate that token IDs are not only within bounds but are also minted and assigned to a valid address. In general NFTs can be burned and hence a good practice is to check that they cannot be used in the selection process.
The following mitigation addresses both issues:
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.