The contract is designed to allow the owner to recover ownership using a backup account. However, this process can be compromised due to the lack of a beneficiary address check, enabling an outsider to take ownership and steal all funds.
The `InheritanceManager::inherit` does not verify the msg.sender
is a beneficiary, so an outsider can take the contract ownership if the beneficiaries.length
is equal to 1.
The following test in InheritanceManagerTest.t.sol demonstrates how an outsider can steal contract ownership:
The original owner will lose access to the contract.
The attacker will take ownership and can steal all funds.
Foundry
Add a check to compare the sender's address with the beneficiary address to ensure that only a valid backup account can inherit ownership.
Additionally, as discussed in other submissions, the beneficiaries data structure can be changed to a mapping (mapping(address => bool)). This approach enables efficient verification without requiring loops and an outsider will not be able to set `isInherited` to true without the knowledge of a beneficiary. However, if a mapping is used, the withdrawal mechanism will also need modifications, as each user will be responsible for withdrawing their own funds.
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.