Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

buyPresent() not spending callers tokens

Summary

The buyPresent() function burning the tokens of the receiver and minting the NFT to the msg.sender

Vulnerability Details

The buyPresent() function can be used to buy a present for someone, but it will try to burn that person's tokens.

The following test will fail as it tries to burn tokens of the receiver.

function testBuyPresent() public {
// mig test without this block
vm.startPrank(santa);
santasList.checkList(user, SantasList.Status.EXTRA_NICE);
santasList.checkTwice(user, SantasList.Status.EXTRA_NICE);
vm.stopPrank();
vm.warp(santasList.CHRISTMAS_2023_BLOCK_TIME() + 1);
vm.startPrank(user);
santaToken.approve(address(santasList), 1e18);
santasList.collectPresent();
santasList.buyPresent(santa);
assertEq(santasList.balanceOf(user), 1);
assertEq(santaToken.balanceOf(user), 1e18);
vm.stopPrank();
}

Impact

Users can loose funds.

Tools Used

Recommendations

The buyPresent() function should be changed so that it burns the tokens of the msg.sender.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

buyPresent should use msg.sender

Current implementation allows a malicious actor to burn someone else's tokens as the burn function doesn't actually check for approvals.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.