Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Invalid

Vulnerability in changeHost Function: Host Lockout Due to Participant Status Check

Summary

The function changeHost in the smart contract contains a vulnerability that allows the current host to potentially lose the ability to change the host if they are removed from the list of participants after the deadline has passed. This occurs because the function checks whether the new host is a participant, but does not account for the possibility that the current host could be removed from the list of participants, preventing them from changing the host.

Vulnerability Details

In the function changeHost, the following condition is checked:

function changeHost(address _newHost) external onlyHost {
if(!participant[_newHost]) {
revert OnlyParticipantsCanBeHost();
}
host = _newHost;
emit NewHost(host);
}

This ensures that only participants who have contributed to the event can become the new host. However, the current host can potentially be excluded from the list of participants (i.e., participant[host] is set to false), especially after the deadline has passed. This can occur if the host decides to opt out of participating. Once the host is removed from the list of participants, they will no longer be able to call this function successfully to assign a new host, even though they should still be able to do so.

This is problematic because:

  1. The function changeHost only works if both the new host (_newHost) and the current host are participants.

  2. After the deadline, participants cannot change their participation status (i.e., participant[msg.sender] cannot be set back to true).

  3. If the host is removed from the participant list (i.e., participant[host] = false), the host will not be able to change the host after the deadline, even though they should still be able to perform this privileged action.

Impact

The impact of this vulnerability is that the current host can be locked out of changing the host after they are no longer a participant in the event. This could lead to a situation where the event becomes unmanageable if the host is no longer available to assign a new host or make decisions regarding the event.

Tools Used

Manual

Recommendations

To fix this vulnerability, the changeHost function should be modified to allow the current host to change the host regardless of whether they are a participant. A simple way to resolve this issue is to modify the condition that checks whether the new host is a participant to only apply to the new host, and allow the current host to execute the function without restrictions.

Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!