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

SantaToken does not mint and burn `PURCHASED_PRESENT_COST`

Summary

The protocol grants to users with a EXTRA_NICE status with a NFT and 1e18 SantaToken as presents. The SantaToken can used to buy a NFT for a friend using the SantasList::buyPresent function but according to the docs:

buyPresent: A function that trades 2e18 of SantaToken for an NFT. This function can be called by anyone

Currently users only need to pay half the price to buy the present and if the protocol implements the intended price, they would not be able to do so.

Impact

Users does not pay the correct price.

Tools Used

Manual verification

Recommendations

Update SantasList::buyPresent and SantasList::collectPresent as such:

function buyPresent(address presentReceiver) external {
- i_santaToken.burn(presentReceiver);
+ i_santaToken.burn(presentReceiver, PURCHASED_PRESENT_COST);
_mintAndIncrement();
}
function collectPresent() external {
if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
revert SantasList__NotChristmasYet();
}
if (balanceOf(msg.sender) > 0) {
revert SantasList__AlreadyCollected();
}
if (s_theListCheckedOnce[msg.sender] == Status.NICE && s_theListCheckedTwice[msg.sender] == Status.NICE) {
_mintAndIncrement();
return;
} else if (
s_theListCheckedOnce[msg.sender] == Status.EXTRA_NICE
&& s_theListCheckedTwice[msg.sender] == Status.EXTRA_NICE
) {
_mintAndIncrement();
- i_santaToken.mint(msg.sender);
+ i_santaToken.mint(msg.sender, PURCHASED_PRESENT_COST);
return;
}
revert SantasList__NotNice();
}

In SantaToken update _mint and _burn as such:

- function mint(address to) external {
+ function mint(address to, uint256 amount) external {
if (msg.sender != i_santasList) {
revert SantaToken__NotSantasList();
}
- _mint(to, 1e18);
+ _mint(to, amount);
}
- function burn(address from) external {
+ function burn(address from, uint256 amount) external {
if (msg.sender != i_santasList) {
revert SantaToken__NotSantasList();
}
- _burn(from, 1e18);
+ _burn(from, amount);
}
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.