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

Wrong winner could be emitted in the `RapBattle::Battle` event

Summary

In some rare cases, wrong winner can be emitted in the RapBattle::Battle event due to faulty boolean expression used in the ternary operator.

Vulnerability Details

In cases when the random number is equal to defenderRapperSkill, the defender should win the battle and their address should be emitted as the last parameter of the RapBattle::Battle event. But because < is used in place of <= in the expression random < defenderRapperSkill on line 67 of RapBattle contract, the challenger's address will be emitted instead.

Impact

Wrong winner could be emitted that can lead to inconsistencies in the frontend.

Tools Used

Foundry

Recommendations

- emit Battle(msg.sender, _tokenId, random < defenderRapperSkill ? _defender : msg.sender);
+ emit Battle(msg.sender, _tokenId, random <= defenderRapperSkill ? _defender : msg.sender);
Updates

Lead Judging Commences

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

Contradictory battle result event

Support

FAQs

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