Christmas Dinner

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

When signing-up by sending ether to the contract directly, the `participant` mapping is never updated to count the participation

Description The ChristmasDinner::receive function does not update the participant mapping when being triggered, it only updates the etherBalance mapping.

Impact

Users who sign up by sending ETH directly to the contract are not added to the dinner, not counting their intended participation.

Proof of Concepts

Add the followiing test to ChristmasDinnerTest.t.sol file.

function test_signingUpBySendingEtherDoesntAddTheParticipant() public {
address payable _cd = payable(address(cd));
vm.deal(user1, 10e18);
vm.prank(user1);
// The user sends ETH directly
(bool sent,) = _cd.call{value: 1e18}("");
require(sent, "transfer failed");
//Their intended participation is not included
assert(cd.getParticipationStatus(user1) == false);
}

Recommended mitigation

Add the following change to the code.

receive() external payable {
etherBalance[msg.sender] += msg.value;
+ participant[msg.sender] = true;
emit NewSignup(msg.sender, msg.value, true);
}
Updates

Lead Judging Commences

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

receive does not update participation status

Support

FAQs

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