The _adjustRatePerSecond
function in Sablier allows stream senders to modify token streaming rates. When increasing rates, it should ensure the stream's remaining balance can sustain the new rate for a reasonable duration. However, the current implementation lacks this validation, potentially allowing rates that could drain streams instantly rather than maintaining gradual token distribution.
Here's the current vulnerable implementation:
The issue is that this implementation only checks if the new rate is different from the current rate. It doesn't validate whether the stream's balance can sustain the new rate for a reasonable duration. This allows for setting rates that could deplete the entire stream balance almost instantly.
Here's an example of how this can be exploited:
In this scenario, a stream meant to last 100 seconds at 1 token/second can be modified to drain in just 1 second.
Streams can be configured to drain instantly rather than gradually
Users can bypass intended streaming duration by setting unsustainable rates
Recipients may not receive tokens over expected timeframes
Protocol's core streaming mechanism becomes unreliable
Risk of premature stream depletion
Here's how the function should be implemented with proper balance validation:
This improved version adds crucial balance validation by:
Calculating the remaining available balance
Determining how long the stream can last at the new rate
Ensuring the stream will last at least a minimum duration
Reverting if the new rate would deplete the balance too quickly
This protection maintains the protocol's core purpose of gradual token streaming and prevents instant balance depletion through rate manipulation.
The fix ensures that any rate adjustment must allow the stream to maintain operation for a reasonable minimum duration, preserving the intended token distribution mechanism.
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.