Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Improper Beneficiary Array Management Leading to Fund Distribution Issues

Summary : The removeBeneficiary function deletes array elements without compacting the array, leaving address(0) entries that disrupt equal fund distribution in withdrawInheritedFunds

Vulnerability Details: In removeBeneficiary, delete beneficiaries[indexToRemove] sets the element to address(0) without adjusting the array length. In withdrawInheritedFunds, the loop iterates over all elements, attempting to send funds to address(0):

  • For ETH, this may burn funds or revert.

  • For ERC20, safeTransfer may revert, halting distribution.
    Additionally, _getBeneficiaryIndex returns 0 if the beneficiary isn’t found, deleting the first element incorrectly.

Impact: High. This breaks the third invariant by potentially losing funds to address(0) or preventing full distribution, leaving assets stuck in the contract

Tools Used

Recommendations: Properly compact the array in removeBeneficiary and add existence checks:

function removeBeneficiary(address _beneficiary) external onlyOwner {
for (uint256 i = 0; i < beneficiaries.length; i++) {
if (_beneficiary == beneficiaries[i]) {
beneficiaries[i] = beneficiaries[beneficiaries.length - 1];
beneficiaries.pop();
_setDeadline();
return;
}
}
revert("Beneficiary not found");
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 5 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Incorrect removal from beneficiary list causes funds to be send to 0 address

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.