The buyPresent
function allows an external attacker to burn other users' SantaTokens and mint NFTs for themselves. This vulnerability stems from the improper use of the burn function in the context of the token's approval mechanism, potentially leading to unauthorized token depletion and unfair NFT acquisition.
The vulnerability lies in the buyPresent
function's logic, where it calls i_santaToken.burn(presentReceiver) without adequate checks to ensure that the caller is the rightful owner of the SantaTokens or has received explicit permission from the token owner.
This flaw is exacerbated by the fact that the approve function in the token contract emits an Approval event, which can be monitored by attackers. They can use this information to call buyPresent with the address of a user who has approved the SantasList
contract to spend their tokens, leading to unauthorized burning of the user's tokens and minting of NFTs for the attacker's benefit.
Santaslist.sol
:
@solmate/src/tokens/ERC20.sol
The consequences of this vulnerability are twofold:
Unauthorized Token Burning: Attackers can deplete other users' SantaTokens without their consent, leading to financial loss for the token owners.
Unfair NFT Acquisition: The same attackers can unjustly acquire NFTs, disrupting the intended distribution mechanism and potentially devaluing the NFTs due to unauthorized increase in supply.
The following test uses the attacker's address to call the buyPresent function after the user approved SantasList
address.
Terminal:
Foundry
Update buyPresent Logic: Amend the function to ensure it checks whether the caller has the right to burn tokens for the specified presentReceiver. This could involve verifying that the caller is the token owner or has been authorized by the owner.
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.