Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

Premature Return in Estate Buy-Out Logic Prevents Complete Distribution and NFT Burn

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:

  1. Setup: Assume there are three beneficiaries: A, B, and C.

  2. Execution: Beneficiary B calls buyOutEstateNFT to trigger the buy-out process.

  3. 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.

  4. 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.


Updates

Lead Judging Commences

0xtimefliez Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

buyOutNFT has return instead of continue

0xtimefliez Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

buyOutNFT has return instead of continue

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.