The buyPresent method is vulnerable as it allows an attacker to burn another user's tokens using the address presentReceiver parameter.
This leads to the attacker receiving a free mint since the _mintAndIncrement function mints the token for msg.sender, not presentReceiver.
The buyPresent method is unsafe as it uses the provided address parameter for the burn function, while _mintAndIncrement mints the token to msg.sender. This discrepancy is shown below:
The following PoC illustrates how an attacker can burn another user's token and receive a free NFT:
Copy this test into the SantasListTest.t.sol file and execute the following command:
As demonstrated in this test, after a user approves token spending and claims their reward, an exploiter can immediately burn the user's token and mint a free token for themselves.
This vulnerability is of high severity as it allows any user to obtain a free mint by burning another user's token.
Forge testing framework
The buyPresent method should be modified to use msg.sender instead of address presentReceiver in the burn function to ensure that the token is burned and the NFT is minted for the correct user:
By implementing this change, the correct user's token will be burned, and the NFT will be minted for them, eliminating the current vulnerability.
Current implementation allows a malicious actor to burn someone else's tokens as the burn function doesn't actually check for approvals.
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.