Unchecked arithmetic operations will lead to incorrect calculations for users
Summary
In multiple files (TaxCalculator.sol, LinearRangeCurve.sol, Listings.sol, ProtectedListings.sol, UniswapImplementation.sol), unchecked arithmetic operations will lead to incorrect calculations for users as underflows and overflows may occur without proper validation.
Root Cause
Arithmetic operations are performed without ensuring values remain within data type bounds:
_previousCompoundedFactor, perSecondRate, or _timePeriod are large enough to cause overflow.
ProtectedListings.sol Line 273:
listingsOfType_ and collectionToken.denomination() are large.
UniswapImplementation.sol Line 607:
swapAmount and ammFee are large values close to their maximum limits.
External pre-conditions
N/A.
Attack Path
Users invoke functions with vulnerable arithmetic operations:
For example, functions that calculate interest rates, utilization rates, or fees.
Underflow or overflow occurs during calculations:
Arithmetic operations exceed the data type limits.
Incorrect values are computed, or transactions revert:
Users receive wrong amounts or experience transaction failures.
Impact
The users suffer incorrect calculations, which can lead to financial losses or contract instability due to underflow and overflow errors in arithmetic operations.
rcadob
High
Unchecked arithmetic operations will lead to incorrect calculations for users
Summary
In multiple files (
TaxCalculator.sol
,LinearRangeCurve.sol
,Listings.sol
,ProtectedListings.sol
,UniswapImplementation.sol
), unchecked arithmetic operations will lead to incorrect calculations for users as underflows and overflows may occur without proper validation.Root Cause
Arithmetic operations are performed without ensuring values remain within data type bounds:
Underflow Errors:
TaxCalculator.sol
:Line 69: Subtraction
_utilizationRate - UTILIZATION_KINK
may underflow if_utilizationRate
is less thanUTILIZATION_KINK
.LinearRangeCurve.sol
:Line 60: Subtraction
end - start
may underflow ifend
is less thanstart
.Listings.sol
:Line 933: Subtraction
_listing.duration - (block.timestamp - _listing.created)
may underflow ifblock.timestamp - _listing.created
exceeds_listing.duration
.Overflow Errors:
TaxCalculator.sol
:Line 90: Multiplication of large values without checks may overflow.
ProtectedListings.sol
:Line 273: Multiplication of large numbers may overflow.
UniswapImplementation.sol
:Line 607: Multiplying
swapAmount
byammFee
may overflow.Internal pre-conditions
Underflow Conditions:
TaxCalculator.sol
Line 69:_utilizationRate
is less thanUTILIZATION_KINK
.LinearRangeCurve.sol
Line 60:end
is less thanstart
.Listings.sol
Line 933:block.timestamp
exceeds_listing.created + _listing.duration
.Overflow Conditions:
TaxCalculator.sol
Line 90:_previousCompoundedFactor
,perSecondRate
, or_timePeriod
are large enough to cause overflow.ProtectedListings.sol
Line 273:listingsOfType_
andcollectionToken.denomination()
are large.UniswapImplementation.sol
Line 607:swapAmount
andammFee
are large values close to their maximum limits.External pre-conditions
N/A.
Attack Path
Users invoke functions with vulnerable arithmetic operations:
Underflow or overflow occurs during calculations:
Incorrect values are computed, or transactions revert:
Impact
The users suffer incorrect calculations, which can lead to financial losses or contract instability due to underflow and overflow errors in arithmetic operations.
PoC
Underflow in
TaxCalculator.sol
Line 69:Overflow in
UniswapImplementation.sol
Line 607:Overflow in
UniswapImplementation.sol
Line 607:Mitigation
Use Safe Arithmetic Operations:
Add Validation Checks:
For Underflow:
TaxCalculator.sol
Line 69:LinearRangeCurve.sol
Line 60:Listings.sol
Line 933:For Overflow:
TaxCalculator.sol
Line 90:ProtectedListings.sol
Line 273:UniswapImplementation.sol
Line 607:Implement Safe Math Libraries:
SafeMath
for versions of Solidity before 0.8.Limit Input Values: