Christmas Dinner

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

[H-06] User sending ether to the contract is not registered as participant

Description:

ChristmasDinner::receive() does not register the address of the doner as a participant breaking the contract promise.

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

Impact:

Impact: Hight. Funds are sent to the contract and the user will not be registered. It breaks the contract logic.

Likelyhood: High. If a user sends only ether to the contract he will not be registered for the dinner and will not be able to attend.

Proof of Concept:

function test_depositEtherAndBecomeParticipant() public {
address payable _cd = payable(address(cd));
vm.deal(user1, 10e18);
vm.prank(user1);
(bool sent, ) = _cd.call{value: 1e18}("");
require(sent, "transfer failed");
assertEq(user1.balance, 9e18);
assertEq(address(cd).balance, 1e18);
assertEq(cd.getParticipationStatus(user1), true);
}

user1 is not on the participant list after sending ether to the contract.

Recommended Mitigation:

add the address to participation list.

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

Lead Judging Commences

0xtimefliez Lead Judge 7 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.