Buoy3Pool.safetyCheck
can underflow
#103
Labels
3 (High Risk)
bug
Something isn't working
disagree with severity
duplicate
This issue or pull request already exists
Handle
cmichel
Vulnerability details
Vulnerability Details
The
safetyCheck
function performs an unsafe subtraction on two uint256 before casting them toint256
.The subtraction can underflow and the cast to
int256
can either fail and revert the transaction (if greater thantype(int256).max
), or, fit into anint256
and corrupt thesafetyCheck
making it always returnfalse
.If the
lastRatio[i]
is even just 1 "wei" less than_ratio
, the result will betype(uint256).max
and the cast toint256
will fail due to the size limit of signed integers.All functions implementing the
safetyCheck
will revert and the protocol can become stuck and unusable.Recommended Mitigation Steps
As only the absolute value is relevant the following code should work without having to cast to
int256
:The text was updated successfully, but these errors were encountered: