Non Beneficiary can take over the contract in case only one beneficiary is added to the contract
Incase there is a single beneficiary that is added to the contract, an attacker that has not been added to the list of beneficiaries can call this function: https://github.com/CodeHawks-Contests/2025-03-inheritable-smart-contract-wallet/blob/9de6350f3b78be35a987e972a1362e26d8d5817d/src/InheritanceManager.sol#L217
js```
js```
and thereby take over the contract as the owner after the deadline.
Nonbeneficiary can inherit the contract
Foundry
The owner added just one beneficairy to the contract but the attacker in the code below was not added and was still able to be the new owner of the contract
Copy and paste this in InheritanceManager.t.sol
Then run
forge test --mt test_inheritByNonBeneficiary
The ouput will be
js```
Ran 1 test for test/InheritanceManagerTest.t.sol:InheritanceManagerTest
[PASS] test_inheritByNonBeneficiary() (gas: 90939)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.79ms (968.60µs CPU time)
js```
Recommendations
Incase of one beneficiary, the Owner should be change to the only beneficiary in the array of beneficiaries instead of the caller of the contract i.e msg.sender should be replaced by the only beneficiary in the array
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.