Beginner FriendlyFoundryGameFi
100 EXP
View results
Submission Details
Severity: medium
Valid

`MartenitsaEvent::stopEvent` does not remove the list of partecipants not allowing recurring users to join new events

Summary

The stopEvent function in the MartenitsaEvent contract fails to remove participants from the list of participants after the event ends. This oversight prevents recurring users from joining new events as their addresses remain stored in the _participants mapping.

Vulnerability Details

The stopEvent function is designed to end the event and remove the producer role from participants. However, it lacks the functionality to remove participants from the list entirely. As a result, addresses of previous participants persist in the _participants mapping, which may inadvertently block them from joining future events.

Proof of Code

Add this test to the MartenitsaEvent.t.sol test suite.

function testJoinNewEvent() public eligibleForReward {
martenitsaEvent.startEvent(1 days);
vm.startPrank(bob);
marketplace.collectReward();
healthToken.approve(address(martenitsaEvent), 10 ** 18);
martenitsaEvent.joinEvent();
vm.stopPrank();
vm.warp(block.timestamp + 1 days + 1);
martenitsaEvent.stopEvent();
//start a new event
martenitsaEvent.startEvent(1 days);
vm.startPrank(bob);
marketplace.collectReward();
healthToken.approve(address(martenitsaEvent), 10 ** 18);
vm.expectRevert(bytes("You have already joined the event"));
martenitsaEvent.joinEvent();
vm.stopPrank();
}

Impact

Users who have participated in previous events remain listed as participants even after the event has ended. This prevents them from joining new events since the contract mistakenly believes they are still active participants.

Tools Used

Manual review, Foundry

Recommendations

You can implement the following changes to the stopEvent function.

Code
/**
* @notice Function to remove the producer role of the participants after the event is ended.
*/
function stopEvent() external onlyOwner {
require(block.timestamp >= eventEndTime, "Event is not ended");
for (uint256 i = 0; i < participants.length; i++) {
isProducer[participants[i]] = false;
+ _participants[participants[i]] = false;
}
}
Updates

Lead Judging Commences

bube Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

_participants is not updated

Support

FAQs

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