During the security review, it was observed that Snek-Raffle users can burn their own NFTs to decrease the total supply of tokens. This way, they could effectively DoS the project by not letting other users mint new NFTs or try to raffle again with the intention of winning the same token ID again with a different rarity.
The Snek-Raffle project inherits from the snekmate library. Is is specifically using the ERC721 library with the functions below:
Notice this means that users of the Snek-Raffle project can burn their own tokens. This does not necessarily imply a security flaw. However, see how the fulfillRandomWords()
function is calculating the rarity of newly-minted tokens and the new ID of such token:
The total supply is used to assign the rarity to the new tokens and to indicate the id of the token to mint. Therefore, an attacker could decrease the total supply by burning a token of their own and break the logic above. Two different cases appear:
If the token burnt is the last one minted, this would let the attacker raffle again with the goal of gaining the same NFT with a different rarity.
If the token burnt is not the last one minted, this would break the logic of the fulfillRandomWords()
function as it would always revert when trying to mint ERC721._mint(recent_winner, ERC721._total_supply())
an already-existing token.
Raffle users could burn their NFTs to DoS the entire raffle or to update the rarity of their own tokens.
The function below is an example of an attacker burning its own token (last one minted) and winning the raffle again to mint a new token with the same token ID as the previously burned:
Another, more complex, test can be done to DoS the whole Snek-Raffle project:
Manual analysis and Foundry.
Consider removing the burn functionality to make sure minted NFTs exist forever. Another solution would be to update the way rarity and minting is calculated so it is not based on the total supply.
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.