The buyOutEstateNFT
function in the InheritanceManager contract uses an early return in its beneficiary loop. When iterating through the list of beneficiaries, the loop immediately returns upon finding the caller’s address. This premature exit can prevent the distribution of funds to beneficiaries located later in the array, resulting in incomplete and unequal distribution of funds.
The buyOutEstateNFT function is intended to distribute the buyout amount among all beneficiaries except the caller (who pays the share). It calculates a final amount to be distributed and then iterates over the beneficiaries array. However, the loop uses an early return:
When the caller is found (for example, if the caller is the second beneficiary), the function returns immediately without transferring funds to beneficiaries that follow in the array. This results in an incomplete fund distribution—potentially leaving some beneficiaries without their share—though the funds remain safe, they are not allocated as intended.
Direct Impact: Beneficiaries later in the array may receive no funds, leading to financial discrepancies in the intended equal distribution.
Manual code review
Foundry (Forge) unit tests simulating the call flow to buyOutEstateNFT
Remove the early return in the loop and ensure that funds are distributed to all beneficiaries (excluding the caller). For example, accumulate transfers for all beneficiaries and perform them, or use a loop that skips over the caller without aborting the entire distribution process.
Alternatively, restructure the logic to first collect the shares for all beneficiaries and then perform transfers, ensuring complete distribution.
Add comprehensive tests to validate that each beneficiary (other than the caller) receives the correct share.
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.