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.