A critical vulnerability has been identified in the InheritanceManager contract's beneficiary management system. The _getBeneficiaryIndex function returns incorrect indices for non-existent beneficiaries, which can lead to removal of wrong beneficiaries and incorrect fund distribution.
The vulnerability exists in the beneficiary management system:
Index Return Issue:
When a beneficiary is not found, the function returns index 0
This causes confusion with the actual beneficiary at index 0
Allows removal of wrong beneficiaries through removeBeneficiary
Test Demonstration Shows:
Three beneficiaries are added (user1, user2, user3)
Querying index for non-existent beneficiary returns same index as an existing beneficiary
This allows removing wrong beneficiary
Results in incorrect fund distribution
From the test:
The test proves this by:
Adding three beneficiaries
Showing that _getBeneficiaryIndex(notBeneficiary) returns same index as valid beneficiary
Demonstrating fund distribution is affected:
user1 receives 0 funds
user2 and user3 receive equal shares
Funds are incorrectly distributed due to wrong beneficiary management
Critical severity. The vulnerability allows:
Removal of wrong beneficiaries
Loss of backup wallet functionality
Incorrect inheritance fund distribution
Potential complete loss of access to funds if wrong beneficiary is removed
Manual code review
Foundry test framework
Custom test cases demonstrating the index collision
Function return value analysis
Modify beneficiary index management:
Add additional safety checks:
Validate beneficiary existence before operations
Add explicit beneficiary status tracking
Implement beneficiary operation events for tracking
Enhance error handling:
Add specific error messages for beneficiary operations
Implement proper revert messages for invalid operations
Add events for critical beneficiary changes
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.