When the killRavana
function is called in the Dussehra.sol
contract, the funds are not divided correctly. This results in a remainder of the division that is not accounted for. This remainder will be locked in the contract and not be able to be withdrawn by the organizer.
Performing totalAmountGivenToRam = (totalAmountByThePeople * 50) / 100;
in the Dussehra.sol:killRavana
will not always result in a number that is truly 50% of the total amount. This happens when an entry fee, passed to the contracts constructor in Wei is not divisible by 2 when multiplied by the number of participants.
After the organizer and the selected Ram have received their funds, the remainder of the division will be locked in the contract. This will result in the organizer not being able to withdraw the funds.
Stateless Fuzz Testing.
Proof of Concept:
Dussehra.sol
is deployed with an entry fee in wei (fuzzed) that is not divisible by 2 when multiplied by the number of participants.
Enter participants with the fuzzed entrance fee.
Warp to the time when the event is finished
Organizer calls selectRamIfNotSelected
and killRavana
The funds are divided and the remainder is locked in the contract.
Organizer recieves half of the funds during the killRavana
call.
The selected ram calls 'withdraw` and recieves the other half, while the remainder is locked in the contract.
Steps to Reproduce:
Create a new test file called LockedFundsAfterWithDraw.t.sol
Add the code below to the file.
Run the test with forge test --match-path test/LockedFundsAfterWithDraw.t.sol -vvv
Proof of Code:
Performing totalAmountGivenToRam = (totalAmountByThePeople * 50) / 100;
is already a more accurate way to calculate the 50% of the total amount. However, the killRavana
function should be updated to ensure that after the 50% is calculated, the remainder of contract funds are sent to the organizer. This will prevent any funds from being locked in the contract.
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.