The withdrawInheritedFunds
function in the InheritanceManager
contract uses simple division to distribute funds among beneficiaries. This approach creates dust amounts (small remainders) that remain locked in the contract when the total balance is not perfectly divisible by the number of beneficiaries.
When distributing either ETH or ERC20 tokens, the function calculates the amount per beneficiary using simple division:
In both cases, if the total amount is not perfectly divisible by the number of beneficiaries (divisor
), the remainder will be truncated due to Solidity's integer division behavior. This remainder stays in the contract with no mechanism to distribute it.
For example, if there are 3 beneficiaries and 100 tokens to distribute, each will get 33 tokens (100 ÷ 3 = 33.33...), leaving 1 token permanently stuck in the contract.
Locked Funds: Small amounts of assets become permanently trapped in the contract, especially when distributing large amounts among many beneficiaries or with tokens having high decimal precision.
Incomplete Inheritance: The goal of the contract is to fully distribute all assets upon inheritance, but this goal isn't achieved due to the dust amounts.
Accumulation Over Time: If multiple tokens are withdrawn over time, the dust amounts can accumulate to significant values.
Reduced Trust: Beneficiaries might be concerned that some funds are being withheld if they notice discrepancies between total balance and distributed amounts.
The severity is medium because while funds are lost, the impact is typically small relative to the total distributed amount, and the contract functionality still largely achieves its purpose.
Manual code review
Distribute Remainder to Last Beneficiary:
Modify the distribution logic to give the remainder to the last beneficiary.
Skip Zero Addresses:
Additionally, to complement the fix for the earlier "gaps in beneficiaries array" issue:
Add Event Emission:
Emit events to improve transparency:
These changes will ensure that all funds are properly distributed without leaving dust amounts in the contract.
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.