Anyone can call the RapBattle::getRapperSkill function with input argument the defenderTokenId and see the rapperSkill of this tokenId.
In the RapBattle contract an event OnStage is emittet after someone calls the RapBattle::goOnStageOrBattle function and is waiting for an opponent. The event has arguments: defender, tokenId and credBet.
The function RapBattle::getRapperSkill is public and anyone can call it with input argument the tokenId of the defender.
That allows an user to use the tokenId of the defender (or defenderTokenId) and see the rapperSkill. Then this user can decide if he has chance to win the battle and if he has, he will call the RapBattle::goOnStageOrBattle function. In that way the malicious user can choose the opponent for the battle according the rapperSkills. Additionally, there is a risk of front-running, where a user with knowledge of the defender's rapper skill may attempt to get their transaction included first by paying a higher gas price.
The function RapBattle::getRapperSkill can be called by anyone. Also, the address, tokenId and credBet of the user who is waiting for battle (defender) are emitted on event and can be seen by anyone. (Also, they are stored in public variables and anyone can see their values on blockchain.) So another user who wants to participate in battle can use the tokenId of the defender to see the defender's rapper skills.
There is a variable totalBattleSkill that serves as the range for the random number and how the individual skill levels influence the probability of winning. The higher a rapper's skill level relative to the totalBattleSkill, the greater the range of numbers that will result in their victory.
The following test function testSeeOpponentSkill shows this scenario. User calls goOnStageOrBattle and is waiting for an opponent. Bob see his tokenId and calls the function getRapperSkill with it. Then Bob can compare his rapper skills with the defender's skills and decide if he will participate in the battle (if he has a chance to win the opponent). Bob can pay higher gas price to front-run his transaction and participate in battle with the chosen opponent. In that way Bob will gain unfair advantage to choose the most appropriate opponent in order to win the battle.
You can add the test function in the file OneShot.t.test.sol and execute it with the foundry command: forge test --match-test "testSeeOpponentSkill" -vvv.
Manual Review, Foundry
The RapBattle::getRapperSkill function is only called in RapBattle::_battle function. So the getRapperSkill function can be internal and nobody will be able to call it in order to see the opponent's rapperSkill.
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.