Mystery Box

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

Potential delete Issue in MysteryBox::transferReward()

Summary

The MysteryBox::transferReward() function uses delete to remove an item from the rewards array, which can leave "holes" in the data structure.

Vulnerability Details

Affected Code

delete rewardsOwned[msg.sender][_index];

Impact

This creates gaps in the rewardsOwned array, leading to potential inefficiencies and unexpected behavior.

Tools Used

  • Visual Studio Code

  • Solidity

  • Foundry

Recommended Mitigation

Use a more efficient method to remove the reward by replacing it with the last item and reducing the array length.

rewardsOwned[msg.sender][_index] = rewardsOwned[msg.sender][rewardsOwned[msg.sender].length - 1];
rewardsOwned[msg.sender].pop();
Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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