Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: medium
Invalid

User can deposit ether using the `ChristmasDinner::deposit` function.

Summary

A user can deposit ether using the `ChristmasDinner::deposit` function, in the deposit function, from the netspac: `Does not allow signing up with Ether, for Ether signups use receive()`. This would interupt the functionality of the protocol.

Vulnerability Details

Add the following to the test suite and run `forge test --mt ChristmasDinner::deposit -vvv`
```javascript
function test_depositEtherUsingDepositFunction() public {
vm.warp(1 + 3 days);
vm.startPrank(user1);
//depositng weth
cd.deposit(address(weth), 1e18);
assertEq(weth.balanceOf(user1), 1e18);
assertEq(weth.balanceOf(address(cd)), 1e18);
console.log("weth deposited");
vm.stopPrank();
}
```

Impact

A user can sign up with ether, using the ChristmasDinner::deposit, which shouldn't be done, following the natspec instruction.

Tools Used

foundry, manual analysis

Recommendations

Include a check in the deposit function that reverts if the token is weth.

```diff
+ if(_token == address(i_WETH)){
+ revert canOnlyDepositWethUsingRecieve();
+ }
```
Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!