The cost to buy NFT as mentioned in the docs is 2e18 via the SantasList::buyPresent
function but in the actual implementation of buyPresent function it calls the SantaToken::burn function which doesn't take any parameter for amount and burns a fixed 1e18 amount of SantaToken, thus burning only half of the actual amount that needs to be burnt, and hence user can buy present for their friends at cheaper rates.
Along with this the user is able to buy present for themselves but the docs mentions that present can be bought only for other users.
The vulnerability lies in the code in the function SantasList::buyPresent
at line 173 and in SantaToken::burn
at line 28.
The function burn
burns a fixed amount of 1e18 SantaToken whenever buyPresent
is called but the true value of SantaToken that was expected to be burnt to mint an NFT as present is 2e18.
Add the test in the file: test/unit/SantasListTest.t.sol
.
Run the test:
Protocol mentions that user should be able to buy NFT for 2e18 amount of SantaToken but users can buy NFT for their friends by burning only 1e18 tokens instead of 2e18, thus NFT can be bought at much cheaper rate which is half of the true amount that was expected to buy NFT.
User can buy a present for themselves but docs strictly mentions that present can be bought for someone else.
Manual Review, Foundry Test
Include an argument inside the SantaToken::burn
to specify the amount of token to burn and also update the SantasList::buyPresent
function with updated parameter for burn
function to pass correct amount of tokens to burn.
Update the SantaToken::burn
function
Update the SantasList::buyPresent
function
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.
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.