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.
In the function changeHost, the following condition is checked:
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:
The function changeHost only works if both the new host (_newHost) and the current host are participants.
After the deadline, participants cannot change their participation status (i.e., participant[msg.sender] cannot be set back to true).
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.
Manual
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.