amountPerBeneficiary, finalAmount and finalAmount per beneficiary are variables used for the calculation of each beneficiary share to withdraw.
amountPerBeneficiary is used in withdrawInheritedFunds()
finalAmount and finalAmount per beneficiary are used in buyOutEstateNFT()
These variables which are of type uint256, are calculated by division of the total amount to inherit by the number of beneficiaries. Because Solidity doesn't support floating point/noninteger numbers, in situations where the result is a floatin point/noninteger number will result in incorrect calculations and amounts per beneficiaries.
For example:
ethAmountAvailable = 4 ethereum and beneficiaries.length = 3, the result amountPerBeneficiary wil equal 1.33, which Solidity will round to 1, resulting in .33 ethereum loss per beneficiary, here totaling 1 ethereum lost.
If ethAmountAvailable = 1 ethereum and beneficiaries.length = 3, the result amountPerBeneficiary wil equal 0.33, which Solidity will round to 0, resulting in .33 ethereum loss per beneficiary, here totaling 1 ethereum lost.
This incorrect calculation will lead to loss of funds, stuck in the inheritanceManager contract
The result of the calculations for amountPerBeneficiary, finalAmount and finalAmount per beneficiary will be incorrect, therefore, beneficiaries will receive less value than expected or in some cases 0 value.
Manual review
Use fixed-point arithmetics, by introducing and using a precision factor, in this case the ETH decimals value
These changes should make the division operations correct, avoiding fund loss and contract incosistent behavior.
Side note: I am writing these submission on mobile, being away from laptop at the moment, so I can not test the code. Thanks for understanding.
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.