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

Calling the 'SantasList.sol::buyPresents' function only costs 1 SantaToken to buy the NFT instead of 2 SantaToken

Summary

Calling the 'SantasList.sol::buyPresents' function only costs 1 SantaToken instead of 2. As per the documentation, it should cost 2 SantaToken to mint an NFT.

Vulnerability Details

Calling the 'SantasList.sol::buyPresents' function calls the 'SantaToken.sol::burn' function but it only burns 1e18 worth of SantaToken to mint a new NFT. This burn function should burn 2e18 worth of SantaToken as per the documentation.

Impact

The below test passes as true showing that a user can mint an NFT while only spending 1 SantaToken.

function testBuyPresent() public {
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(user);
assertEq(santasList.balanceOf(user), 2);
assertEq(santaToken.balanceOf(user), 0);
vm.stopPrank();
}

Tools Used

--Foundry

Recommendations

It is recommended to increase the burn amount in the 'SantaToken.sol::burn' function to 2e18

function burn(address from) external {
if (msg.sender != i_santasList) {
revert SantaToken__NotSantasList();
}
- _burn(from, 1e18);
+ _burn(from, 2e18);
}
Updates

Lead Judging Commences

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

Price is not enforced in buyPresent

This line indicates that the intended cost of presents for naughty people should be 2e18: https://github.com/Cyfrin/2023-11-Santas-List/blob/6627a6387adab89ae2ba2e82b38296723261c08a/src/SantasList.sol#L87 PURCHASE_PRESENT_COST should be implemented to enforce the cost of presents.

Support

FAQs

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