The _calculateStreamedAmount function in the SablierV2LockupDynamic contract does not explicitly validate whether the provided streamId corresponds to an existing stream. This lack of validation can lead to accessing uninitialized storage, returning incorrect values, and potentially causing unexpected behavior in the contract.
A user or another contract function calls a function that internally calls _calculateStreamedAmount with an invalid streamId.
The function executes and returns a value based on uninitialized data from the _streams mapping, which could be zero or default values.
The returned value is used to determine how much the recipient can withdraw or how much the sender has streamed, leading to incorrect financial outcomes.
Users may withdraw less than they are entitled to or be unable to access funds that should be available, resulting in financial discrepancies and loss of trust in the platform.
The function does not perform a check to ensure that the provided streamId corresponds to an existing, initialized stream. If an invalid streamId is passed, the function may return incorrect values, which could lead to the misrepresentation of the streamed amount.
Manual review
Implement a check within _calculateStreamedAmount to verify that the streamId corresponds to an existing and active stream. This could involve checking if stream properties such as startTime and endTime are initialized and make sense in the context of the current block timestamp.
Consider reverting the transaction or providing a clear error message when the function is called with an invalid streamId, to prevent propagation of incorrect calculations.
The updated _calculateStreamedAmount function includes additional checks to mitigate the issue of data validation:
It verifies that the stream exists by checking that its startTime is not zero.
It includes a check to ensure that the stream has at least one segment before proceeding with the calculation.
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.