The InheritanceManager contract uses the delete
operator to remove beneficiaries from the beneficiaries array, which leaves zero address gaps. These gaps can lead to erroneous fund distribution calculations and may even create denial-of-service (DoS) scenarios when the array is processed.
When a beneficiary is removed using the delete
operator, the beneficiary's slot in the array is set to the zero address rather than being removed entirely. As a result, subsequent operations that iterate over the beneficiaries array—for example, splitting funds equally during withdrawal—will include these zero addresses. This can cause incorrect division of funds, as the total number of beneficiaries used in the calculation does not reflect the actual intended recipients. In certain scenarios, the presence of these gaps could also be exploited to trigger unexpected behavior or even a DoS when processing the array.
Direct Impact: Incorrect fund splits can result, where valid beneficiaries receive less than their fair share.
Indirect Impact: In extreme cases, if the array is processed without filtering out zero addresses, it could lead to a denial-of-service (DoS) situation, disrupting the distribution of funds.
Manual code review
Foundry (Forge) unit tests to simulate beneficiary removal and fund distribution calculations
Replace the use of delete
with a more robust mechanism for managing beneficiary removals. For instance, implement an approach that either shifts array elements to maintain a compact array or use a mapping to track active beneficiaries.
If retaining an array structure, ensure that functions iterating over beneficiaries explicitly skip zero addresses.
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.