buyOutEstateNFT allows one beneficiary (the caller) to take control of an underlying asset by distributing to the rest of the beneficiaries their corresponding shares (buying them out). However, unless the caller is the last beneficiary, later beneficiaries will not receive their shares.
A beneficiary can call InheritanceManager::buyOutEstateNFT to buy out a Real World Assert (e.g real estate) represented by an NFT.
The caller-beneficiary pays finalAmount tokens into the contract ([1]). Then, the contract distributes this amount equally among all other beneficiaries (excluding the caller) ([2]). Finally, the NFT is burned, removing it from circulation ([3]). The for-loop will check if beneficiaries[i] corresponds to msg.sender. If that's the case, buyOutEstateNFT will return. However, unless the caller is the last beneficiary, later beneficiaries will not receive their shares.
Consider the following scenario:
owner calls createEstateNFT
owner adds alice as beneficiary
beneficiary[0] == alice
owner adds bob as beneficiary
beneficiary[1] == bob
deadline expires
alice calls inherit
alice calls buyOutEstateNFT
buyOutEstateNFT will return early since beneficiary[0] == alice
bob doesn't receive his token share
Place test_buyOutEstateTokenShareLoss in InheritanceManagerTest.t.sol:
And run the test:
Fund inheritance is a core feature of the InheritanceManager contract. The premature loop-exit return in buyOutEstateNFT can break the distribution logic.
Manual review
Foundry
Adjust the if-check and remove the early return.
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.