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

Unrestricted inherit Function

Summary

The inherit function in the InheritanceManager contract can be called by anyone if the beneficiaries array has only one address. This could allow unauthorized users to take control of the contract.

Vulnerability Details

  • Code:

    function inherit() external {
    if (block.timestamp < getDeadline()) {
    revert InactivityPeriodNotLongEnough();
    }
    if (beneficiaries.length == 1) {
    owner = msg.sender;
    _setDeadline();
    } else if (beneficiaries.length > 1) {
    isInherited = true;
    } else {
    revert InvalidBeneficiaries();
    }
    }

The function does not restrict access to beneficiaries, allowing anyone to call it if there is only one beneficiary.

Impact

An attacker could exploit this to become the owner of the contract.

Tools Used

Manual reviewe

Recommendations

Restrict the inherit function to only allow beneficiaries to call it:

function inherit() external {
if (block.timestamp < getDeadline()) {
revert InactivityPeriodNotLongEnough();
}
if (beneficiaries.length == 1) {
require(msg.sender == beneficiaries[0], "Caller is not the sole beneficiary");
owner = msg.sender;
_setDeadline();
} else if (beneficiaries.length > 1) {
isInherited = true;
} else {
revert InvalidBeneficiaries();
}
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 9 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Inherit depends on msg.sender so anyone can claim the contract

Support

FAQs

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

Give us feedback!