RapBattle._battle random can be predicted and lead to stealing Credibility tokens from users.
Function _battle in RapBattle contract use weak random sources which a known values for attacker or can be manipulated by attacker:
https://github.com/Cyfrin/2024-02-one-shot/blob/47f820dfe0ffde32f5c713bbe112ab6566435bf7/src/RapBattle.sol#L62C1-L63C116
block.timestamp is known by attacker
block.prevrandao is known by attacker
msg.sender can be manipulated by attacker using create2
totalBattleSkill is known by attacker
Add this test to OneShotTest.t.sol and run via forge test --mt testWeakRandomness to see it success.
Output:
Predictable random in RapBattle._battle leads to the attacker winning every battle that already has a defender and stealing Credibility tokens from the user.
Manual review, foundry.
Consider using a cryptographically provable random number generator, such as Chainlink VRF.
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.