Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Invalid

Security Vulnerabilities

Summary

Access Control Weaknesses

Vulnerability Details

The onlyBeneficiaryWithIsInherited modifier uses a while loop that can go out of bounds (i < beneficiaries.length + 1).

Impact

This can potentially cause undefined behavior or revert the transaction.

Tools Used

/**
* @dev this while loop will revert on array out of bounds if not
* called by a beneficiary.
*/
modifier onlyBeneficiaryWithIsInherited() {
uint256 i = 0;
while (i < beneficiaries.length + 1) {
if (msg.sender == beneficiaries[i] && isInherited) {
break;
}
i++;
}
_;
}

Recommendations

Fix the onlyBeneficiaryWithIsInherited modifier to prevent out-of-bounds errors

modifier onlyBeneficiaryWithIsInherited() {
uint256 i = 0;
while (i < beneficiaries.length) {
if (msg.sender == beneficiaries[i] && isInherited) {
_;
return;
}
i++;
}
revert NotOwner(msg.sender);
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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