Christmas Dinner

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

Lack of Deadline Enforcement for Native ETH Payments

Summary

  • Users are able to register for the event even after the deadline by paying through native ether, which could undermine the event's rules and planning, allowing late registrations that were not intended.

Impact

  • Allowing users to register after the deadline by paying with native ether creates unfair participation, disrupts event planning, and may lead to resource shortages or confusion for the host.

Tools Used

Foundry

Proof Of Concept

  • Add the below code in ChristmasDinnerTest.t.sol:ChristmasDinnerTest

function test_POC_Registration_Is_Open_After_Deadline_Through_Native_ETH()public{
console.log("Deadline :",DEADLINE);
console.log("Starting TIME-STAMP=",block.timestamp);
vm.warp(100);
address EXPLOITER=makeAddr("EXPLOITER");
startHoax(EXPLOITER,1 ether);
console.log("Deadline :",DEADLINE);
(bool check1,)=address(cd).call{value: 1 ether}("");
console.log("Ending TIME-STAMP=",block.timestamp);
console.log("Exploiter participation status :",cd.getParticipationStatus(EXPLOITER));
require(check1,"Deposit through NATIVE ETH failed");
}
  • Add the above code in the ChristmasDinnerTest.t.sol:ChristmasDinnerTest.

  • shell forge test --match-test test_POC_Registration_Is_Open_After_Deadline_Through_Native_ETH -vv

  • You will get output as folowing

    • deadline : 7

    • Starting TIME-STAMP= 1

    • Deadline : 7

    • Ending TIME-STAMP= 100

    • Exploiter participation status : true

Recommendations

  • You can mitigate this by making necessary checks in receive() function. to ensure any payments are not accepted after deadline.

receive() external payable {
+ if(block.timestamp>deadline){
+ revert BeyondDeadline();
+ }
participant[msg.sender]=true;
etherBalance[msg.sender] += msg.value;
emit NewSignup(msg.sender, msg.value, true);
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

receive() function independant from deadline

Support

FAQs

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