A vulnerability exists in the Dussehra smart contract, allowing participants to pay the entrance fee and enter the festival even after Ram has been selected. This results in Ether being locked in the contract with no way of retrieving it. Additionally, it is unnecessary for users to enter the festival and pay the fee after the event has ended.
The enterPeopleWhoLikeRam function does not check if Ram has already been selected before allowing participants to pay the entrance fee. As a result, participants can continue to pay the fee and enter the festival even after Ram has been selected, leading to locked funds in the contract.
This vulnerability is highly likely to occur because users could unknowingly pay the entrance fee after the Ram is selected, leading to financial loss. The locked funds could not be retrieved by either the organizer or Ram, resulting in a permanent loss of the paid Ether.
The PoC demonstrates the vulnerability by simulating the entry of a participant (player3) attempting to pay the entrance fee after the Ram has already been selected. This results in the participant's Ether becoming locked within the contract, as shown by the test case.
After running the test we can confirm the vulnerability:
The vulnerability in the Dussehra smart contract, which allows participants to pay the entrance fee and enter the festival even after the Ram has surely been selected, has several significant impacts:
Locked Funds: Ether paid by participants gets permanently locked in the contract. Neither the organizer nor Ram* can retrieve these funds, leading to a financial loss for participants.
Participant Misguidance: Users might unknowingly pay the entrance fee after the event has ended, believing they can still participate and become the Ram. This results in unnecessary expenditure and frustration among participants.
Contract Integrity: Allowing payments after the event's conclusion undermines the contract's integrity. It indicates a lack of proper checks and balances within the contract's logic, reducing trust in the smart contract's functionality.
Potential Exploitation: If the killRavana function is called repeatedly, it will continuously recalculate the funds to send. Furthermore, if the withdraw function is called, funds can only be "retrieved" after waiting for more users to enter the event post-conclusion, which makes no sense and allows for potential fund mismanagement. Ram can only take money from the contract once the funds inside equal what should be sent to Ram (would be considered as stealing). However, since the event is over, any new deposits would be unnecessary and constitute an exploit of the contract logic.
Manual Code Review
Foundry
To mitigate this vulnerability, update the enterPeopleWhoLikeRam function to include a check for RamIsNotSelected. This ensures that participants cannot pay the entrance fee and enter the festival after the Ram has been selected, thus preventing locked funds and maintaining the integrity of the event.
After updating the code we run the test again, and it fails:
By adding the check for RamIsNotSelected the contract will prevent participants from entering the festival and paying the entrance fee after the event has ended, thus avoiding locked funds.
By implementing this check, the contract ensures that participants cannot enter the event after the Ram has been selected, thereby preventing locked funds and maintaining the integrity of the festival.
It is the user's responsibility to check the date of the event.
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.