Mystery Box

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

Use of `delete` Does Not Reduce Array Length

Summary

The delete operation used in the transferReward, claimAllRewards, and claimSingleReward functions does not reduce the size of the array, potentially leading to logical issues and inefficiencies.

Vulnerability Details

The contract uses delete to remove elements from the rewardsOwned array. However, this does not reduce the array's length, leaving "empty slots" that could cause issues when the contract logic assumes the array length reflects the number of valid entries.

Impact

These empty slots could lead to logical errors, particularly in functions that iterate through the array. This could result in faulty reward transfers or claims.

Tools Used

Manual Code Review

Recommendations

Instead of using delete, consider shifting array elements after an item is removed to maintain a contiguous array. Alternatively, use a more sophisticated data structure like a mapping for rewards.

Updates

Appeal created

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

A user can poison the `rewardsOwned` of another user via `transferReward` of an empty reward index

Gas Limit Exhaustion in `claimAllRewards` Function

Support

FAQs

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