Because addresses which have previously collected presents are not independently tracked, and only their current balance tracked, NICE and EXTRA_NICE users can infinitely collect presents, which is very NAUGHTY.
collectPresent
only checks for msg.sender
's current NFT balance, which is a very naïve check for whether the user has already collected. A user could easily transfer the NFT to an alt of their own, or transfer it to someone NAUGHTY, making all the work Santa did in checking the list twice moot.
In the worst case, a single NICE or EXTRA_NICE user could give a Santa NFT to the entire world, multiple times over. An EXTRA_NICE user could further be a SantaToken
whale, given they'd get 1e18 SantaToken
with each call. If SantaToken was traded on exchange, or people provided liquidity, a lot of value could be destroyed. The reputational damage to Santa would be immense.
forge test
. I wrote a passing test that proves that an EXTRA_NICE user can easily mint 101 NFTs, and have 101e18 SantaToken
. The same would hold true for NICE users, just that they wouldn't have the additional SantaToken
balance.
Easiest thing to do would be to maintain a mapping of addresses that collected presents already, and check whether the address was a key in the mapping prior to allowing collecting. Recommend mapping vs array for gas efficiency so you don't spin through a large array looking for the address.
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.