Mystery Box

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

Inefficient Use of delete in claimSingleReward()

Summary

In the claimSingleReward(uint256 _index) function, the delete operation is used to remove a reward from the rewardsOwned array. This operation zeroes out the element but does not shrink the array, which leads to the creation of gaps. Over time, this can result in a sparse array that causes inefficiencies, especially when iterating over or accessing elements.

Vulnerability Details

Gaps in the array can cause incorrect or inefficient behavior when accessing rewards.

  • Over time, this may also lead to higher gas costs or unexpected contract behavior.

  • This can expose the contract to potential reentrancy attacks if an attacker manipulates the array’s state before it’s fully settled.

Impact

lead to financial losses due to improper reward handling.

Tools Used

manual

Recommendations

Replace the delete operation with a safe array removal pattern, such as swapping the element to be deleted with the last element and then using .pop() to remove it. This ensures the array remains contiguous and properly managed.

Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

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

Give us feedback!