The InheritanceManager
contract does not prevent the same address from being added multiple times as a beneficiary. This vulnerability allows certain beneficiaries to receive a larger share of the inheritance than intended, breaking the contract's core assumption of equal fund distribution.
The addBeneficiery
function lacks a check to prevent adding duplicate beneficiary addresses:
The withdrawInheritedFunds
function distributes funds based on the length of the beneficiaries array:
When a beneficiary appears multiple times in the array, they will receive multiple shares of the inheritance, creating an unfair distribution.
This vulnerability directly impacts the fairness of inheritance distribution:
Beneficiaries added multiple times receive a proportionally larger share of the inheritance
Other legitimate beneficiaries receive less than their intended share
This could be exploited intentionally to favor certain beneficiaries
Violates the core contract functionality of equal distribution
The impact is rated as medium because:
It does not directly lead to fund loss for the contract
But it does lead to incorrect fund distribution
It breaks the core assumption of equal distribution
Manual code review and Foundry testing
Add the following test to InheritanceManager.t.sol
This test adds
user1
twice. We calculate the proportion of funds by dividing the total funds by the number of beneficiaries (4 entries for 3 unique addresses).
We then assert thatuser1
gets twice the proportion while other users get one proportion each.
Run the test
Implement a check to prevent duplicate beneficiary addresses:
Alternatively, implement a helper function for reusability:
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.