When users withdraw accumulated debt, the stream's snapshotDebtScaled
is updated differently on 2 different conditions :
https://github.com/Cyfrin/2024-10-sablier/blob/main/src/SablierFlow.sol#L823-L840
One of the condition will update the snapshotTime
as well while the other condition won't.
The issue relies in the fact that when snapshotTime
is NOT updated in a particular scenario.
All the functions relying solely on the returned value of the internal _ongoingDebtScaledOf()
function will return a wrong value.
The reason for that is _ongoingDebtScaledOf()
performs its internal calculations based upon the elapsed time which is obtained through the subtraction block.timestamp - snapshotTime
.
The below is a coded PoC that can be pasted in tests\integration\concrete\depletion-time-of\depletionTimeOf.t.sol
that demonstrates the ongoingDebtScaled
returning a wrong value :
The functions relying on _ongoingDebtScaledOf()
will return a wrong value leading to wrong calculations
Manual review
Systematically update the snapshotTime
when the snapshotDebtScaled
is updated.
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.