Sablier

Sablier
DeFiFoundry
53,440 USDC
View results
Submission Details
Severity: medium
Valid

Missing start time check in steamed amount calculation in `SablierV2LockupLinear` contract

Summary

In _calculateStreamedAmount function of SablierV2LockupLinear contract, the start timestamp of the stream is not checked versus current timestamp, which leads to overflow in math and as a result some functionalities do not work.

Vulnerability Details

In _calculateStreamedAmount function, the calculation of streamed amount is done in unchecked block.

unchecked {
// Calculate how much time has passed since the stream started, and the stream's total duration.
uint256 startTime = uint256(_streams[streamId].startTime);
UD60x18 elapsedTime = ud(blockTimestamp - startTime);
UD60x18 totalDuration = ud(endTime - startTime);
// Divide the elapsed time by the stream's total duration.
UD60x18 elapsedTimePercentage = elapsedTime.div(totalDuration);
// ...
}

Since the validity of startTime is not checked in the function, so startTime can surely be bigger than blockTimestamp. For information, there's a validation of cliffTime but it is usually zero when there is no cliff time.

As a result, overflow in math occurs and elapsedTime will be near to type(uint256).max, and this big number causes a revert in div function because of overflow.

This means _calculateStreamedAmount function reverts when startTime > blockTimestamp`.

Impact

The issue specifically prevents senders from cancelling the stream before it starts.

Tools Used

Manual Review

Recommendations

There should be a validation where it returns zero if a stream is not started.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
bladesec Submitter
about 1 year ago
inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

In LL context `_calculateStreamedAmount` reverts if start time is in the future and clif = 0

Support

FAQs

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