Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Precision loss in score

Summary

The conversion from int8 score to uint256 shares in the withdraw function of ThePredicter.sol could lead to precision loss.

Vulnerability Details

The line uint256 shares = uint8(score); first converts int8 to uint8, then to uint256. Negative scores are lost in this conversion.

Impact

Players with negative scores see their score up to 0. As it is not a critical vuln since they can't withdraw, the scoreboard would not reflet the real score of the players.

Recommendations

Add a check to the reward calculation to handle negative scores correctly:

uint256 shares = score > 0 ? uint256(uint8(score)) : 0;
Updates

Lead Judging Commences

NightHawK Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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