Wrong use of balanceOf
allows users to collect more than 1 NFT.
The logic used to determine whether the user can already collect NFT or not is wrong as the user can transfer the NFT he/she collected to his/her another address, making the balance of the current user's address's NFT
0
again.
Hence, satisfying the (balanceOf(msg.sender) > 0)
condition again.
Due to the flawed logic, user can repeat the same behavior of first collecting NFT and then transferring it to his/her another address again and again.
Hence, collecting countless NFTs and defeating the major purpose of this function and the whole contract.
Manual Review
To mitigate the vulnerability, create a mapping(address => bool)
that tracks whether user
has collected the NFT
or not.
Here's how you can modify the function:
Relying on balanceOf > 0 in collectPresent() allows the msg.sender to send their present to another address and then collect again.
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.