The buyOutEstateNFT function uses an incorrect mathematical formula to calculate buyout amounts, resulting in residual funds being permanently locked in the contract and beneficiaries receiving less than their fair share.
In the InheritanceManager contract, the buyOutEstateNFT function contains a critical mathematical error in how it calculates and distributes funds during an NFT buyout. The function is intended to allow one beneficiary to buy out others' shares of a jointly inherited NFT.
The problematic code is located in the buyOutEstateNFT function:
The issue occurs in two parts:
Incorrect Calculation Order: The function calculates finalAmount as (value / divisor) * multiplier. In Solidity, which uses integer division, performing division before multiplication causes precision loss. This approach fundamentally breaks the financial invariant that each beneficiary should receive an equal portion of the NFT's value.
Double Division Problem: After the initial calculation of finalAmount, the function distributes it by again dividing by divisor in the line IERC20(assetToPay).safeTransfer(beneficiaries[i], finalAmount / divisor). This second division results in significantly less tokens being distributed than were collected from the buyer.
The combination of these errors violates a core property of the contract: that beneficiaries should receive fair compensation for their share of the NFT. Furthermore, since the contract collects more tokens than it distributes, funds become permanently trapped in the contract with no mechanism to retrieve them.
it affects the buyOutEstateNFT function, which is used to distribute funds among beneficiaries. The incorrect calculation could result in beneficiaries receiving less than they should, potentially leading to disputes or financial loss.
very much likely to occur
Consider a scenario with 3 beneficiaries and an NFT valued at 100 USDC:
With more beneficiaries, the percentage of locked funds increases:
With 4 beneficiaries = 43% of funds become locked
With 10 beneficiaries = 73% of funds become locked
The function should be rewritten to:
Calculate each beneficiary's fair share directly
Transfer exactly that amount to each beneficiary (except the buyer)
Ensure the buyer pays the correct amount to the contract
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.