Lack of validation checks will cause transaction reverts for users
Summary
In multiple contracts (TaxCalculator.sol, LinearRangeCurve.sol, BaseImplementation.sol, CollectionShutdown.sol, Listings.sol), lack of checks before division operations will cause transaction reverts for users as division by zero errors occur when denominators are zero.
Root Cause
Divisions are performed without ensuring that denominators are non-zero:
UTILIZATION_KINK equals 1 ether, making 1 ether - UTILIZATION_KINK zero.
Line 117:
_initialCheckpoint.compoundedFactor is zero.
LinearRangeCurve.sol
Line 60:
end equals start, so end - start is zero.
BaseImplementation.sol
Line 199:
ONE_HUNDRED_PERCENT is zero.
CollectionShutdown.sol
Lines 150, 245, 310, 343:
ONE_HUNDRED_PERCENT is zero.
Other variables in denominators are zero.
Listings.sol
Line 933:
_listing.duration is zero.
External pre-conditions
N/A.
Attack Path
Users or contracts invoke functions that perform divisions without checking denominators:
For example, a user calls a function that calculates interest or fees.
A division by zero occurs due to zero denominators:
The calculation attempts to divide by zero, causing an exception.
Transactions revert, leading to denial of service:
The function execution halts, and the user's transaction fails.
Impact
The affected parties cannot execute transactions involving these calculations, resulting in:
Denial of Service:
Users are unable to perform essential operations, such as calculating interest, buying items, or participating in governance.
Contract Functionality Halted:
Critical contract functions cannot proceed, affecting the overall system stability.
PoC
Example for LinearRangeCurve.sol Line 60:
// Scenario where end equals start
uint128 spotPrice = 1 ether;
uint128 delta = packDelta(1000, 1000); // start = end = 1000
uint256 numItems = 1;
// Unpack delta to get start and end
(uint32 start, uint32 end) = unpackDelta(delta);
// This will cause a division by zero
uint256 inputValue = numItems * (spotPrice * (end - block.timestamp) / (end - start));
// Since end == start, (end - start) == 0, causing division by zero
Similar PoCs for other instances:
TaxCalculator.sol Line 117:
uint256 _initialCheckpoint.compoundedFactor = 0; // Denominator is zero
uint256 compoundedFactor = _currentCheckpoint.compoundedFactor * 1e18 / _initialCheckpoint.compoundedFactor;
// Division by zero occurs here
BaseImplementation.sol Line 199:
uint256 ONE_HUNDRED_PERCENT = 0;
uint256 beneficiaryFee_ = _amount * beneficiaryRoyalty / ONE_HUNDRED_PERCENT;
// Division by zero occurs here
Mitigation
Add Checks Before Division Operations:
Ensure denominators are not zero before performing divisions.
require(denominator != 0, "Denominator cannot be zero");
Fit Cyan Kookaburra
Low/Info
Lack of validation checks will cause transaction reverts for users
Summary
In multiple contracts (
TaxCalculator.sol
,LinearRangeCurve.sol
,BaseImplementation.sol
,CollectionShutdown.sol
,Listings.sol
), lack of checks before division operations will cause transaction reverts for users as division by zero errors occur when denominators are zero.Root Cause
Divisions are performed without ensuring that denominators are non-zero:
TaxCalculator.sol
:1 ether - UTILIZATION_KINK
without checking if the result is zero._initialCheckpoint.compoundedFactor
without verifying it's non-zero.LinearRangeCurve.sol
:end - start
without ensuringend
is greater thanstart
.BaseImplementation.sol
:ONE_HUNDRED_PERCENT
without confirming it's non-zero.CollectionShutdown.sol
:ONE_HUNDRED_PERCENT
without checks for zero denominators.Listings.sol
:_listing.duration
without verifying it's non-zero.Internal pre-conditions
TaxCalculator.sol
UTILIZATION_KINK
equals1 ether
, making1 ether - UTILIZATION_KINK
zero._initialCheckpoint.compoundedFactor
is zero.LinearRangeCurve.sol
end
equalsstart
, soend - start
is zero.BaseImplementation.sol
ONE_HUNDRED_PERCENT
is zero.CollectionShutdown.sol
ONE_HUNDRED_PERCENT
is zero.Listings.sol
_listing.duration
is zero.External pre-conditions
N/A.
Attack Path
Users or contracts invoke functions that perform divisions without checking denominators:
A division by zero occurs due to zero denominators:
Transactions revert, leading to denial of service:
Impact
The affected parties cannot execute transactions involving these calculations, resulting in:
Denial of Service:
Contract Functionality Halted:
PoC
Example for
LinearRangeCurve.sol
Line 60:Similar PoCs for other instances:
TaxCalculator.sol
Line 117:BaseImplementation.sol
Line 199:Mitigation
Add Checks Before Division Operations:
Specific Mitigations:
TaxCalculator.sol
Line 69:LinearRangeCurve.sol
Line 60:BaseImplementation.sol
Line 199:Listings.sol
Line 933:Initialize Constants Properly:
ONE_HUNDRED_PERCENT
are set correctly and cannot be zero.Validate Input Parameters: