When the beneficiaries array contains exactly one address, the inherit function allows any external caller to become the contract’s owner after the 90-day inactivity period. This lack of access control creates a severe security vulnerability, as an attacker can seize control of the contract and its assets simply by calling inherit().
The vulnerable code is within the inherit function:
solidity
No Access Control:
The function is external, making it callable by anyone.
In the beneficiaries.length == 1 case, owner = msg.sender assigns ownership to the caller without any verification (e.g., checking if msg.sender is the beneficiary or the original owner).
Security Flaw:
After 90 days, anyone can call inherit() and become the owner, gaining full control over the contract’s assets and functions restricted by onlyOwner.
Complete Takeover: An attacker can steal all contract funds (ETH and ERC20 tokens) and manipulate its state (e.g., add/remove beneficiaries, interact with external contracts).
High Severity: This is a critical vulnerability, as it allows unauthorized control over a contract designed to manage inheritance, which typically holds significant assets.
Reputation Damage: Loss of user trust due to insecure inheritance management.
Manual Review
Restrict the single-beneficiary case to the beneficiary or the original owner. Here’s a fix assuming the beneficiary should inherit ownership:
solidity
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.