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

Issue is Integer Division Truncation happening in `buyOutEstateNFT` function.Solidity performs integer division, any remainder from value / divisor is truncated, which can cause precision loss when multiplied by multiplier.

Summary

The expression:
uint256 finalAmount = (value / divisor) * multiplier; in the contract InheritanceManager::buyOutEstateNFT
is vulnerable to precision loss due to Solidity’s integer division behavior. Since Solidity truncates decimals in division, any remainder from value / divisor is discarded before multiplying by multiplier. This can result in incorrect fund distribution, rounding errors, or unintended discrepancies in calculations.

Vulnerability Details

The expression:
uint256 finalAmount = (value / divisor) * multiplier; in the contract InheritanceManager::buyOutEstateNFT
is vulnerable to precision loss due to Solidity’s integer division behavior. Since Solidity truncates decimals in division, any remainder from value / divisor is discarded before multiplying by multiplier. This can result in incorrect fund distribution, rounding errors, or unintended discrepancies in calculations.

Impact

The contract might underpay or overpay and The error accumulates when dealing with large sums or multiple transactions.consider an example where it breaks

uint256 value = 10;uint256 divisor = 3; // n
uint256 multiplier = 2; // n - 1
uint256 finalAmount = (value / divisor) * multiplier;
value / divisor = 10 / 3 = 3 (Solidity truncates the decimal part, result is 3)
3 * multiplier = 3 * 2 = 6
Solidity truncates 10 / 3 to 3, so we get 6 instead of 6.6667.

Tools Used

Recommendations

A better approach would be multiplication First to Avoid Precision Loss.uint256 finalAmount = (value * multiplier) / divisor;
more accurate than the original approach.

orginal approach - uint256 finalAmount = (value / divisor) * multiplier;

After refactor - uint256 finalAmount = (value * multiplier) / divisor;

Updates

Lead Judging Commences

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

buyOutNFT has wrong denominator

truncation of integers

Support

FAQs

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