The InheritanceManager contract contains a vulnerability in the addBeneficiery
function that allows duplicate beneficiary entries. The core issue stems from the lack of validation before adding a new beneficiary to the array, enabling the same address to be added multiple times.
The impact is that:
A beneficiary added multiple times will receive multiple shares during fund distribution
The inheritance distribution mechanism becomes unfair and unpredictable
In the withdrawInheritedFunds
function, assets are divided by beneficiaries.length
, so duplicate entries receive proportionally more funds
Gas costs for operations that iterate through the beneficiaries array will increase unnecessarily
The following code segment demonstrates the vulnerability:
Consider this scenario:
Owner adds Alice as a beneficiary: addBeneficiery(aliceAddress)
Owner adds Bob as a beneficiary: addBeneficiery(bobAddress)
Owner accidentally (or deliberately) adds Alice again: addBeneficiery(aliceAddress)
When funds are distributed in withdrawInheritedFunds
, the division would be:
Alice would receive 2 * amountPerBeneficiary
while Bob would only receive amountPerBeneficiary
, despite them supposedly having equal shares
This issue affects other functions as well:
buyOutEstateNFT
would send duplicate payments to beneficiaries listed multiple times
inherit
function's behavior could be unpredictable if there are duplicates in the array
To fix this issue, implement a duplicate check in the addBeneficiery
function:
Alternatively, a more gas-efficient approach using a mapping:
Manual Code Review
Logical Analysis
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.