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

Incorrect Calculations in buyPresent()

Summary

Incorrect Calculations in buyPresent function, the contract will be burn 1e18 and not 2e18.

Vulnerability Details

This vulnerability leads to users buy NFTS at a cheaper price because in the
function burn(address from) external {
if (msg.sender != i_santasList) {
revert SantaToken__NotSantasList();
}
_burn(from, 1e18);
}
It automatically burns 1e18 and not 2e18 without taking into consideration PURCHASED_PRESENT_COST variable

Impact

High

Tools Used

Manual Analysis

Recommendations

In the burn function we need to change this line _burn(from, 1e18)
to _burn(from, 2e18); we can delete the PURCHASED_PRESENT_COST because this value is hard coded in the contract

Updates

Lead Judging Commences

inallhonesty Lead Judge almost 2 years 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.