A critical vulnerability has been identified in the InheritanceManager smart contract, specifically in the beneficiary management system. The removeBeneficiary() function implementation creates "ghost entries" in the beneficiaries array when removing addresses. These ghost entries (set to address(0)) continue to be counted during fund distribution, causing a portion of inheritance funds to be sent to the zero address, resulting in permanent loss of assets.
The vulnerability stems from the improper implementation of array element removal in the removeBeneficiary() function:
The function uses Solidity's delete operator, which doesn't remove the element from the array but instead resets it to its default value (address(0)). This creates the following issues:
The beneficiaries array maintains its original length even after elements are removed
The array contains "ghost entries" (zero addresses) where beneficiaries were removed
These ghost entries are still counted in calculations and iterations
Below is the test case that demonstrates this vulnerability:
POC (PROOF OF CONCEPT)
ADD THIS GETTER FUNCTION IN InheritanceManager.sol
Below is the test file for the vulnerability:
As demonstrated in the test, when calculating distributions, the function:
Uses the full length of the array (including ghost entries) as the divisor
Attempts to send funds to all entries in the array, including address(0)
Results in 1/3 of the funds (3 ETH in the test) being sent to the zero address and permanently lost
Direct Financial Loss: A portion of inheritance funds equal to (total funds / number of beneficiaries) is permanently lost for each removed beneficiary, as it's sent to the zero address.
Misleading Fund Distribution: Remaining legitimate beneficiaries receive less than their expected share since funds are incorrectly divided.
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.