Sablier

Sablier
DeFiFoundry
53,440 USDC
View results
Submission Details
Severity: low
Invalid

Loss of Precision Due to Division by Large Numbers

Summary

In the SablierV2NFTDescriptor contract, a potential loss of precision issue has been identified. This occurs when performing division by a large number, which can result in the outcome being zero due to Solidity's inability to handle fractions. This report details the specific instance where this issue occurs and provides recommendations to mitigate the problem.

Vulnerability Details

The issue is identified in the following line of the SablierV2NFTDescriptor contract:

File: v2-core/src/SablierV2NFTDescriptor.sol
200 return streamedAmount * 10_000 / depositedAmount;

https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/SablierV2NFTDescriptor.sol#L200

In this line, the multiplication of streamedAmount by 10,000 is followed by division by depositedAmount. If depositedAmount is a very large number compared to streamedAmount * 10_000, the result of the division may be zero, leading to a loss of precision.

Impact

The loss of precision can result in inaccurate calculations and potentially erroneous logic in the smart contract. This can affect the correct representation and functionality of the system, leading to potential financial discrepancies or unintended behavior in the application.

Tools Used

  • Manual code review

Recommendations

Require Minimum Amounts: Implement a check to ensure that streamedAmount * 10_000 is always larger than depositedAmount before performing the division. For example:

require(streamedAmount * 10_000 > depositedAmount, "Streamed amount too small compared to deposited amount");
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

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