Deleting beneficairy after it has been added will be replaced by the default address in solidity which is 0x00. Once the contract has been inherited, the 'InheritanceManager:withdrawInheritedFunds()' will not be able to distribute the funds due to the presence of an invalid address which is the default address that replaced the deleted address. This is so because use of deletion does not change the length of array and only replaced the element of the array with a default value which is 0x00 incase of address in solidity
1.After adding three users
2.Delete one of the users
3.Inherit and then withdraw the funds after deadline . Copy the code below
4.The Function will revert instead of distributing the funds to ths users
The output will be:
Ran 1 test for test/InheritanceManagerTest.t.sol:InheritanceManagerTest
[PASS] test_withdrawInheritedFundsHasFundStuckedAfterDeletion() (gas: 221081)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.02ms (397.40µs CPU time)
The Funds are going to be stucked within the contract leading to denial of service as the funds can not be withdrawn from the contracts
Instead of using deletion in https://github.com/CodeHawks-Contests/2025-03-inheritable-smart-contract-wallet/blob/9de6350f3b78be35a987e972a1362e26d8d5817d/src/InheritanceManager.sol#L163
replace it with
After this paste the code below in inheritanceManager.t.sol function
and Run this
forge test --mt test_withdrawInheritedFundsAfterDeletion
The output will be
Ran 1 test for test/InheritanceManagerTest.t.sol:InheritanceManagerTest
[PASS] test_withdrawInheritedFundsAfterDeletion() (gas: 230086)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.91ms (718.30µs CPU time)
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.