Mystery Box

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

Using `delete` method does not change the `length` of the array in `rewardsOwned` mapping

Summary

In transferReward and claimSingleReward function we use deleteto remove a reward from an array in the

mapping rewardsOwned, but it does not change the length of the array after deleting an element.

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];
}

Impact

If user will use this protocol for a long time and then use claimAllRewardsfunction , it must use for loopfor the array and it can cause extra gas for the user.

Recommendations

Change the logic.

Updates

Lead Judging Commences

inallhonesty Lead Judge
8 months ago

Appeal created

inallhonesty Lead Judge 8 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.