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

Unauthorized Ownership Transfer When Only One Beneficiary Exists

Summary: In the inherit() function, when there is only one beneficiary, the contract sets owner = msg.sender without verifying that msg.sender is the beneficiary, allowing anyone to claim ownership after the 90-day timelock

Vulnerability Details : When there's only one beneficiary, the inherit() function allows msg.sender to become the owner without verifying they are the beneficiary

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

This violates the invariant that "After the 90 days only the beneficiaries get access to the funds."

Impact : High. Anyone can steal a contract with a single beneficiary once the timelock expires.

Tools Used

Recommendations :

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

Lead Judging Commences

0xtimefliez Lead Judge 5 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.