The buyOutEstateNFT()
function in the InheritanceManager
contract has multiple implementation flaws that prevent it from functioning as intended. The function is designed to allow a beneficiary to buy out an estate NFT and distribute the payment to other beneficiaries in an equal way.
However, the function contains a misplaced return statement, incorrect calculation and distribution of funds, and fails to complete critical operations such as burning the bought NFT.
The key issues are:
The return
statement causes the function to exit prematurely once the buyer is found in the beneficiaries array. All beneficiaries which are at an
index AFTER the beneficiary calling the function won't be paid because of this function early return.
The calculation and distribution of funds results in incorrect amounts being paid to beneficiaries because of a logical issue in the amount computation to be paid to each beneficiary.
The NFT never gets burned because the early return prevents execution from reaching the burn statement.
These issues have various impacts:
Incomplete asset distribution: Beneficiaries that come after the buyer in the array never receive their share of the payment. This leads to a fundamentally unfair distribution system where some beneficiaries are paid while others receive nothing.
Incorrect payment amounts: Even for beneficiaries who do receive payments, the amounts are incorrect. The test below shows that beneficiaries receive 3.75 MOCK tokens instead of the expected 5 MOCK tokens, meaning they receive 25% less than they should (in this example, it depends on the actual count of beneficiaries)
NFT state inconsistency: The NFT is never burned or marked as processed despite the buyer having paid for it. This creates a problematic state where:
Funds locked in contract: A significant portion of funds paid by the buyer remains locked in the contract with no mechanism to distribute them.
The function should be rewritten to fix all the identified issues. A suggestion is described as following:
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.