Mystery Box

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

Gas Costs and Iteration in MysteryBox::claimAllRewards()

Summary

The MysteryBox::claimAllRewards() function iterates over all rewards owned by a user to calculate their value, which can lead to high gas costs and potential failures for users with many rewards.

Vulnerability Details

Affected Code

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

Impact

A user with a large number of rewards may not be able to claim them all at once due to high gas costs.

Tools Used

  • Visual Studio Code

  • Solidity

  • Foundry

Recommended Mitigation

Allow users to claim rewards in smaller batches or optimize the data structure for more efficient reward value calculations.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago

Appeal created

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

Gas Limit Exhaustion in `claimAllRewards` Function

Support

FAQs

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