Mystery Box

First Flight #25
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Unhandled zero balances in function `claimAllReward`

Summary

Unhandled zero balances in function claimAllReward, wich inefficient to loop over rewards with 0 value.

Vulnerability Details

If any of the rewards in function claimAllReward where rewardsOwned[msg.sender] have a value of 0, these rewards are still added to totalValue.

Impact

Although require(totalValue > 0, "No rewards to claim"); prevents claiming when the total value is 0, it's inefficient to loop over rewards with 0 value. Also, the loop should skip rewards with a 0 balance.

Tools Used

Manual review.

Recommendations

Add a condition to skip rewards with 0 value during the accumulation process:

for (uint256 i = 0; i < rewardsOwned[msg.sender].length; i++) {
if (rewardsOwned[msg.sender][i].value > 0) {
totalValue += rewardsOwned[msg.sender][i].value;
}
}
Updates

Appeal created

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

Give us feedback!