In the _calculateStreamedAmount function, the calculation is within an unchecked block.
When the start time is later than the current block's timestamp, an overflow occurs during the calculation.
This can lead to several vulnerabilities:
The sender cannot cancel the stream before the start time because the PRB math library reverts due to the overflowed, extremely large values.
The sender should be able to cancel the stream anytime if it has not been depleted yet.
For specific values, the overflow can result in incorrect calculations (without triggering a revert), allowing some tokens to be withdrawn before the start time.
We can create a linear lockup using the createWithTimestamps function in SablierV2LockupLinear.
Obviously, the start time can be later than the current block.timestamp because some senders may want to start streaming in the future.
After some time, the sender wants to cancel their stream before the start time because they found issues with their plan.
However, this cancellation will be reverted due to an overflow.
Let's explain this step by step with a specific example.
The test for this example will be provided at the end.
The current time is 1714518000, and the start time is 1714690800, which is slightly later.
The cliff time is 0, and the duration is 10,000.
The sender wants to cancel this stream, so they call the cancel function.
Here, we calculate the streamed amount so far by calling the _calculateStreamedAmount function
In the _calculateStreamedAmount function, we don't check whether the start time is later than the current time.
Therefore, in the unchecked block, an overflow occur.
In our case, the elapsed time becomes a large value due to overflow (almost type(256).max), and the total duration is 10,000.
We call the div function in the PRB math library.
In the div function, we multiply by 1e18, and the revert occurs in the mulDiv function
In our test, the revert message is as follows:
Please add below test to the test/integration/concrete/lockup-linear/create-with-timestamps/createWithTimestamps.t.sol
The impact is described in the Summary section.
Manual review
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.