eth_call
Contract call: BoundedStepwiseExponentialPriceAdapter#getPrice
From: 0x5409ed021d9299bf6814279a6a1411a7e866a631
To: 0xc1486de02ef0d31da8e3fc29b64798dab327e7c2
console.log:
-57896044618658097711785492504343953926634992332820282019452584007913129639936
0
Error: VM Exception while processing transaction: reverted with panic code 0x12 (Division or modulo division by zero)
at BoundedStepwiseExponentialPriceAdapter.getPrice (contracts/protocol/integration/auction-price/BoundedStepwiseExponentialPriceAdapter.sol:73)
In two specified price adapters, getPrice() will revert if type(int256).max < _timeElapsed / bucketSize * timeCoefficient < type(uint256).max holds.
This makes an auction stop.
qpzm
medium
Overflow check is imperfect in
BoundedStepwiseLogarithmicPriceAdapter
andBoundedStepwiseExponentialPriceAdapter
.Summary
Overflow check is imperfect in
BoundedStepwiseLogarithmicPriceAdapter
andBoundedStepwiseExponentialPriceAdapter
.Vulnerability Detail
Add this
describe
block in https://github.com/sherlock-audit/2023-06-Index/blob/ef6f395539970e7c70497e895594b2dcbd2f8344/index-protocol/test/protocol/integration/auction-price/boundedStepwiseExponentialPriceAdapter.spec.ts#L104, and runyarn test
.I added hardhat
console.log
to show the overflow. https://github.com/sherlock-audit/2023-06-Index/blob/ef6f395539970e7c70497e895594b2dcbd2f8344/index-protocol/contracts/protocol/integration/auction-price/BoundedStepwiseExponentialPriceAdapter.sol#L58-L67.In
yarn chain
terminal,console.log
is printed.expExpression
returns 0 becauseFixedPointMathLib.expWad
returns 0 if the input is too little. This causes the next linescalingFactor > type(uint256).max / expExpression
to revert with a division by zero panic code. Reference: https://github.com/Vectorized/solady/blob/main/src/utils/FixedPointMathLib.sol#L125Impact
In two specified price adapters,
getPrice()
will revert iftype(int256).max < _timeElapsed / bucketSize * timeCoefficient < type(uint256).max
holds. This makes an auction stop.Code Snippet
Tool used
Manual Review
Recommendation
Check overflow in int256 type.
Duplicate of #1