The InheritanceManager
contract lacks proper zero address validation when managing beneficiaries. It allows zero addresses to be added as beneficiaries and uses delete
on array elements which converts entries to the zero address without removing them. When inheritance is triggered, the contract attempts to distribute funds to all addresses in the array, including zero addresses, which can result in funds being permanently lost.
There are three key components to this vulnerability:
The addBeneficiery
function doesn't validate against zero addresses:
The removeBeneficiary
function uses delete
which sets the array element to address(0) but keeps it in the array:
The withdrawInheritedFunds
function attempts to send funds to all addresses in the array without checking for zero addresses:
When inheritance occurs, the contract will try to distribute funds equally to all entries in the beneficiaries array. If the array contains zero addresses, either from direct addition or as a result of using delete
, the contract will attempt to send funds to address(0). This either results in the funds being permanently lost or in a transaction failure that prevents any beneficiary from receiving their inheritance.
This vulnerability can lead to several serious consequences:
Permanent loss of funds: If ETH is sent to address(0), it becomes permanently inaccessible
Inheritance distribution failure: Attempting to send tokens to address(0) may cause the entire distribution to fail
Incorrect distribution calculations: Zero addresses in the array are counted in the divisor, leading to each beneficiary receiving less than their fair share
Confusion in beneficiary management: The array length doesn't reflect the actual number of valid beneficiaries
The issue is rated as medium severity because:
It can lead to permanent fund loss under specific conditions
It requires particular actions (adding zero address or using the removeBeneficiary function)
It fundamentally breaks the inheritance distribution mechanism
Manual code review and Foundry testing
Add the following test to InheritanceManager.t.sol
Run the test
Add zero address validation in the addBeneficiery
function:
Implement proper array element removal in removeBeneficiary
using swap-and-pop:
Add a check in withdrawInheritedFunds
to 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.