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

Can steal ownership if there is only 1 beneficiary

Summary

Anyone can steal ownership if there is only 1 beneficiary

Vulnerability Details

https://github.com/CodeHawks-Contests/2025-03-inheritable-smart-contract-wallet/blob/main/src/InheritanceManager.sol#L221-L222

/**
* @dev manages the inheritance of this wallet either
* 1. the owner lost his keys and wants to reclaim this contract from beneficiaries slot0
* 2. the owner was inactive more than 90 days and beneficiaries will claim remaining funds.
*/
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();
}
}

Anyone can call the inherit() external function and steal the ownership if there is only one beneficiary :

if (beneficiaries.length == 1) { // <--
owner = msg.sender;
_setDeadline();
}

Impact

Loss of ownership. Anyone can steal the ownership if there is only 1 beneficiary.
This behavior shouldn't be possible.

Tools Used

Github, manual review.

Recommendations

Do not allow such a behavior.

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!