Summary Since the ChoosingRam::increaseValuesOfParticipants
function doesn's update the state of isRamSelected
the Dussehra::killRavana
function is unable to be called even though the player has passed all checks to become the selectedRam.
Vulnerability Details (Proof Of Code)
Add the following to the Dussehra.t.sol
test suite:
function testSelectedRamCantKill() public participants{
vm.startPrank(player3);
vm.deal(player3, 1 ether);
dussehra.enterPeopleWhoLikeRam{value: 1 ether}();
vm.stopPrank();
vm.startPrank(player4);
vm.deal(player4, 1 ether);
dussehra.enterPeopleWhoLikeRam{value: 1 ether}();
console.log();
vm.stopPrank();
vm.startPrank(player4);
choosingRam.increaseValuesOfParticipants(3, 1);
choosingRam.increaseValuesOfParticipants(3, 1);
choosingRam.increaseValuesOfParticipants(3, 1);
choosingRam.increaseValuesOfParticipants(3, 1);
choosingRam.increaseValuesOfParticipants(3, 1);
vm.stopPrank();
console.log(choosingRam.selectedRam());
vm.warp(1728691200 + 1);
vm.expectRevert();
vm.startPrank(player4);
dussehra.killRavana();
vm.stopPrank();
}
The console.log will show Player 4 as the selectedRam, yet they are unable to call Dussehra::killRavana
Impact
Users who have passed the checks in order to complete the event are unable to perform the actions as described in the documentation.
Tools Used
Manual Review,
Foundry,
Recommendations
Update the function to change the state of isRamSelected
to true once a user has been chosen from the ChoosingRam::increaseValuesOfParticipants
function.
+ isRamSelected = true;
ramNFT.updateCharacteristics(tokenIdOfChallenger, true, true, true, true, true);
selectedRam = ramNFT.getCharacteristics(tokenIdOfChallenger).ram;
}
+ isRamSelected = true;
ramNFT.updateCharacteristics(tokenIdOfAnyPerticipent, true, true, true, true, true);
selectedRam = ramNFT.getCharacteristics(tokenIdOfAnyPerticipent).ram;
}