There are no time restrictions on the ChristamsDinner::withdraw function which allows the host to withdraw funds before the deadline has expired. If the host withdraws the funds before the deadline has passed, users will not be able to receive refunds for their deposits.
Based on the specs, the ChristamsDinner::refund function should allow users to issue a refund of their deposits if they decide that they don't want to attend the event anymore. The ChristamsDinner::withdraw function is intended to allow the host to withdraw the funds after the deadline has passed. However, there are no time restrictions on the withdraw function which allows the host to withdraw the funds before the deadline has expired. If the host withdraws the funds before the deadline has passed, users will not be able to receive refunds for their deposits.
User signs up for the Christmas dinner by sending ETH or tokens to the contract.
Host does not check the exact deadline and withdraws the funds a day early.
User can't attend the event anymore and wants to issue a refund.
User calls the refund function but the funds are not available in the contract anymore. The function reverts.
Code:
Place following code into CrhistmasDinnerTest.t.sol:
The impact of this issue is low as no funds are lost. However, it can lead to user dissatisfaction if they are unable to receive refunds for their deposits. If hosts always withdraw funds after deadline, this is not an issue. But mistakes can happen and they are easily avoided by adding a deadline check.
Foundry, manual review, custom test
To avoid mistakes by the host and withdraw funds early, it is recommended to add a deadline check in the ChristmasDinner::withdraw function. This will ensure that the host can only withdraw the funds after the deadline has passed and users have had the opportunity to issue refunds if needed.
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.