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

M-1 Incorrect Winner Emission in _battle Function

Summary

The _battle function emits an incorrect winner due to a discrepancy in the condition used to determine the winner.

Vulnerability Details

The code specifies that the defender wins if random <= defenderRapperSkill:

// If random <= defenderRapperSkill -> defender wins, otherwise they lose
if (random <= defenderRapperSkill) {

However, the Battle event is emitted with the condition random < defenderRapperSkill:

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

The discrepancy between random <= defenderRapperSkill and random < defenderRapperSkill creates inconsistency in determining the winner. The documentation does not provide clarity on the correct condition, but the code suggests that the winner should be determined when random <= defenderRapperSkill.

Impact

This inconsistency affects the accuracy of transaction events, potentially leading to confusion for both users and developers regarding the outcome of battles.

Tools Used

Manual review

Recommendations

To ensure consistency in determining the winner, the following change is recommended:

- 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.