- `SantasList` publishes its price on-chain as a `public constant`, and the specification states it
independently: *"`buyPresent`: A function that trades `2e18` of `SantaToken` for an NFT."*
- No line of the codebase reads that constant. `grep -rn 'PURCHASED_PRESENT_COST' src/ test/` returns
the declaration and nothing else. The price actually charged is a literal in the token.
```solidity
// src/SantasList.sol:87-88
// The cost of santa tokens for naughty people to buy presents
@> uint256 public constant PURCHASED_PRESENT_COST = 2e18; // declared, never read
// src/SantasList.sol:173
i_santaToken.burn(presentReceiver); // takes no amount
// src/SantaToken.sol:32
@> _burn(from, 1e18); // the price actually enforced
```
### Risk
**Likelihood:** High — every call to `buyPresent` charges the wrong amount, unconditionally.
**Impact:**
- Buyers pay `1e18` against a published `2e18` — 50% of the stated price, on every purchase.
- `SantaToken` is minted `1e18` per `EXTRA_NICE` grading, so supply is a direct function of how many
users Santa rewarded. Four gradings fund four purchased presents where the design funds two: the
protocol issues twice the presents its own economics provides for.
- Any front end or integrator reading the public constant to display or quote the price reports a
figure the contract will not charge.
No funds are stolen and no function is denied, which is why the impact is Low rather than Medium.
### Proof of Concept
```solidity
function test_F07_halfThePublishedPrice() public {
_grade(alice, SantasList.Status.EXTRA_NICE);
vm.prank(alice);
list.collectPresent(); *// alice holds 1e18 SANTA*
uint256 before = token.balanceOf(alice);
vm.prank(alice);
list.buyPresent(alice);
assertEq(before - token.balanceOf(alice), 1e18); // charged
assertEq(list.PURCHASED_PRESENT_COST(), 2e18); // published
}
```
### Recommended Mitigation
```diff
// src/SantaToken.sol
- 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);
}
// src/SantasList.sol
- i_santaToken.burn(presentReceiver);
+ i_santaToken.burn(msg.sender, PURCHASED_PRESENT_COST);
```
The `presentReceiver` → `msg.sender` change is [H-3](#h-3)'s mitigation; both are shown because they
touch the same line.
## Description - 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. ## Vulnerability Details 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. ```cpp function buyPresent(address presentReceiver) external { @> i_santaToken.burn(presentReceiver); _mintAndIncrement(); } ``` ```cpp function burn(address from) external { if (msg.sender != i_santasList) { revert SantaToken__NotSantasList(); } @> _burn(from, 1e18); } ``` ## PoC Add the test in the file: `test/unit/SantasListTest.t.sol`. Run the test: ```cpp forge test --mt test_UsersCanBuyPresentForLessThanActualAmount ``` ```cpp function test_UsersCanBuyPresentForLessThanActualAmount() public { vm.startPrank(santa); // Santa checks user once as EXTRA_NICE santasList.checkList(user, SantasList.Status.EXTRA_NICE); // Santa checks user second time santasList.checkTwice(user, SantasList.Status.EXTRA_NICE); vm.stopPrank(); // christmas time 🌳🎁 HO-HO-HO vm.warp(santasList.CHRISTMAS_2023_BLOCK_TIME()); // user collects their present vm.prank(user); santasList.collectPresent(); // balance after collecting present uint256 userInitBalance = santaToken.balanceOf(user); // now the user holds 1e18 SantaToken assertEq(userInitBalance, 1e18); vm.prank(user); santaToken.approve(address(santasList), 1e18); vm.prank(user); // user buy present // docs mention that user should only buy present for others, but they can buy present for themselves santasList.buyPresent(user); // only 1e18 SantaToken is burnt instead of the true price (2e18) assertEq(santaToken.balanceOf(user), userInitBalance - 1e18); } ``` ## Impact - 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. ## Recommendations 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 ```diff -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); } ``` - Update the `SantasList::buyPresent` function ```diff + error SantasList__ReceiverIsCaller(); function buyPresent(address presentReceiver) external { + if (msg.sender == presentReceiver) { + revert SantasList__ReceiverIsCaller(); + } - i_santaToken.burn(presentReceiver); + i_santaToken.burn(presentReceiver, PURCHASED_PRESENT_COST); _mintAndIncrement(); } ```
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.