Mystery Box

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

Not fully checking the length

Summary

The transferReward function checks the index based on the length of the rewardsOwned but it does not check the last reward in the array

Vulnerability Details

In the following line we can see that the requirement is that the index is smaller than the rewardOwned length.

require(_index < rewardsOwned[msg.sender].length, "Invalid index");

It should check the whole length the same way the claimSingleReward function checks meaning it should be:

require(_index <= rewardsOwned[msg.sender].length, "Invalid index");

Impact

This vulnerability kinda breaks the logic of the contract since it doesnt correctly check the full array.

Tools Used

Manual

Recommendations

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

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!