Details:
In the buyOutEstateNFT
function, after transferring the required ERC20 tokens from the caller, the contract iterates over the beneficiaries
array. When it finds that the caller matches an entry (using an if
check), the function immediately executes a return
. This stops the loop, meaning that any beneficiaries positioned after the caller in the array do not receive their share, and the NFT burn operation that follows the loop is never executed.
Root Cause:
The core issue is the use of return
inside the loop. Instead of skipping only the beneficiary that matches the caller, it exits the entire function early. This premature exit prevents the intended distribution of funds to all other beneficiaries and skips the subsequent NFT burn process.
Impact:
Incomplete Fund Distribution: Other beneficiaries do not receive their allocated funds, leading to potential disputes and financial losses.
NFT State Inconsistency: The NFT associated with the estate is not burned, possibly leaving an incorrect or misleading on-chain state.
Contract Misbehavior: The early termination compromises the intended inheritance logic, potentially leading to legal or trust issues among beneficiaries.
Recommendation:
Loop Correction: Replace the return
statement with a continue
so that the loop skips only the caller’s iteration while continuing to distribute funds to remaining beneficiaries.
Post-Loop NFT Burn: Ensure that the NFT burn logic is placed outside the loop so that it is executed after processing all beneficiaries.
Testing: Rigorously test the adjusted logic with various beneficiary orders to confirm that funds distribution and NFT burning occur as expected.
Proof of Concept:
Setup: Assume there are three beneficiaries: A, B, and C.
Execution: Beneficiary B calls buyOutEstateNFT
to trigger the buy-out process.
Current Behavior:
The loop iterates: when beneficiary A is processed, funds are sent.
When beneficiary B is reached (matching the caller), the function returns immediately.
Beneficiary C never receives funds, and the NFT remains unburned.
Expected Behavior:
The loop should skip beneficiary B (the caller) but continue iterating so that beneficiary C receives funds as well, and finally the NFT is burned.
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.