The SablierFlow::_coveredDebtOf
function contains an off-by-one error in the conditional statement that checks if the stream balance is less than or equal to the total debt. Currently, the code only checks if balance < totalDebt
, failing to account for cases where balance
is exactly equal to totalDebt
. This can result in incorrect calculations for covered debt in edge cases.
In the SablierFlow::_coveredDebtOf
function there is an off-by-one error in the condition that checks if the stream balance is less than or equal to the total debt. According to the comment description on the conditional statement If the stream balance is less than or equal to the total debt, return the stream balance.
but the current implementation uses balance < totalDebt
, which does not account for cases where balance
is exactly equal to totalDebt
.
Proof of Concept: In the modified testFuzz_PreDepletion
function below, after computing the new expected covered debt, it checks if the equalbalance is exactly equal to totalDebt. If fail, it asserts that the boundary condition error affects correct result.
Replace the testFuzz_PreDepletion
function in coveredDebtOf.t.sol
with the code below
OR add the code block below to the testFuzz_PreDepletion
function in coveredDebtOf.t.sol
This boundary condition error (Off-by-one error) may lead to incorrect calculations regarding covered debt, potentially results in:
Inaccurate reporting of available funds.
Users being unable to withdraw their exact due amounts when balance
equals totalDebt
.
Manual code review
Static analysis: Slither, aderyn, cloc
To mitigate the off-by-one error in the SablierFlow::_coveredDebtOf
function, modify the condition to correctly check if balance
is less than or equal to totalDebt
. This will ensure accurate calculations in scenarios where balance is exactly equal to totalDebt
, preventing potential withdrawal issues.
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.