Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Valid

Battle winner deciding logic gives advantage to the defender

Summary

In RapBattle.sol, if 'random == defenderRapperSkill' the defender should lose, but they win instead.

Vulnerability Details

Let's use a example for this issue: if defenderRapperSkill = 60 and challengerRapperSkill = 40 then totalBattleSkill = 100. The random number can go from 0 to 99 (100 differentes possibilities in total). For defender to win, values from 0 to 59 (60 possibilities out of 100) are valid; values from 60 to 99 (40 possibilities out of 100) should make the challenger win.

However, 'if (random <= defenderRapperSkill)' makes defender win when random = 60, giving the defender 61% chances to win against 39% for the challenger.

Impact

High impact. All the battle will be disputed with an additional advantage for the defender, which may lead to a victory for the wrong player.

Tools Used

Manual review
Foundry testing

Recommendations

Change the logic of that line if (random <= defenderRapperSkill) {

to

if (random < defenderRapperSkill) {

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Defender's advantage

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Defender's advantage

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.