Challenger can know the random before the battle start by which he can know the outcome of the battle and can call the goOnStageOrBattle function in same transaction if the random number is favorable to him. Otherwise, he can revert the transaction and get his money back.
random number is generated using the keccak256 function which is not secure.
we can use alternative methods to generate a random number like Chainlink's VRF.
Challenger can know the random before he calls the goOnStageOrBattle function and can only call the goOnStageOrBattle function if the random number is favorable to him. Otherwise, he can revert the transaction and get his money back. if random number is favorable to him, he can call the goOnStageOrBattle function in the same transaction and win the battle.
We can use Chainlink's VRF to generate a random number to select the winner.
Paste this test in OneShotTest.t.sol.
Run this command to test the vulnerability.
In the output, you will see that the test case is passing.
Challenger can know the random before the battle and can only call the goOnStageOrBattle function if the random number is favorable to him.
otherwise, he can revert the transaction and get his money back.
manual review
Use Chainlink's VRF to generate a random number to select the winner
Off-chain random number generation can also be used to select the winner.
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.