Mystery Box

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

Discrepancies in Expected Number of Rewards after Deletion

Summary

The transferReward function includes a delete statement that resets a reward to its default value. This can lead to discrepancies in the expected number of rewards, as the array length remains unchanged, potentially causing issues in subsequent reward management operations.

Vulnerability Details

The transferReward function is designed to transfer a specific reward from one user to another.

function transferReward(address _to, uint256 _index) public {
require(_index < rewardsOwned[msg.sender].length, "Invalid index");
rewardsOwned[_to].push(rewardsOwned[msg.sender][_index]);
delete rewardsOwned[msg.sender][_index];
}

The delete operation sets the reward at the specified index to its default value but does not reduce the array's length.

Impact

Users may experience incorrect counts of available rewards or attempts to transfer or claim non-existent rewards, leading to potential user frustration and operational errors.

Tools Used

Manual Review

Recommendations

Discrepancies in the expected number of rewards after deletion can be eliminated by replacing the deleted reward with the last element in the array and reducing the array length.

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

Support

FAQs

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