The InheritanceManager::removeBeneficiary()
function incorrectly removes beneficiaries by simply setting their corresponding array element to its default value (address 0x0). This does not reduce the array's length, leading to an incorrect divisor in withdrawInheritedFunds()
. Consequently, withdrawInheritedFunds()
fails to distribute funds properly and becomes permanently unusable. While the owner can still manually send funds using sendERC20()
, the intended beneficiary withdrawal mechanism is broken.
The removeBeneficiary()
function in InheritanceManager
is intended to remove a beneficiary from the list. However, it achieves this by using delete beneficiaries[indexToRemove]
, which only resets the array element at the specified index to its default value (address 0x0). The array's length remains unchanged. This leads to the following issues:
Incorrect Divisor in withdrawInheritedFunds()
: The withdrawInheritedFunds()
function calculates the share of each beneficiary based on the length of the beneficiaries
array. Since the length is not reduced after removal, the divisor is incorrect, resulting in incorrect fund distribution calculations.
Permanent Failure of withdrawInheritedFunds()
: The function iterates through the beneficiaries
array to send funds. Due to the presence of the default address (0x0), the loop's logic is disrupted, and the function will always revert, making it unusable.
Owner's Manual Fund Distribution: The owner retains the ability to manually send funds using sendERC20()
, bypassing the broken withdrawInheritedFunds()
function.
The provided Foundry test demonstrates this issue:
The core functionality of the InheritanceManager
contract, specifically the automatic distribution of inherited funds via withdrawInheritedFunds()
, is permanently broken. This significantly impacts the contract's intended purpose and user experience.
Manual Review and Foundry Test
The removeBeneficiary()
function should be redesigned to properly remove beneficiaries by shifting the remaining elements and reducing the array's length. Here is the suggested correction:
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.