Mystery Box

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

Lack of zero address validation in `MysteryBox::transferReward` function leads to permanent loss of rewards

Summary

The transferReward function lacks validation for the zero address, allowing rewards to be transferred to an inaccessible address, leading to permanent loss of rewards without affecting the overall contract security.

Impact

The lack of zero address validation can result in permanent loss of rewards if sent to the zero address.

Tools Used

Manual code review

Recommendations

Add zero address validation.

function transferReward(address _to, uint256 _index) public {
+ require(_to != address(0), "Cannot transfer to the zero address");
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: Non-acceptable severity

Support

FAQs

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

Give us feedback!