Open code423n4 opened 2 years ago
This is indeed an edge case and we will update the value checks for the spread values to exclude 10000
. However, from a practical perspective, this is very unlikely to happen. If the goal is to set the lower wall to 0, then the system would just be disabled.
given the warden does fully demonstrate the issue I am going to award as M with the understanding that this is an extreme edge case.
Lines of code
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/modules/RANGE.sol#L242-L250
Vulnerability details
Impact
The
beat
cannot be called anymore and price information will not be updatedCondition:
Proof of Concept
The below proof of concept demonstrates that the
operate
will revert with 100% wallspread. The full test code can be found here as well as the diff fromOperator.t.sol
.In the test, the wallspread was set to 10000, which is 100% (line 51). The price was set so that the lower market should be deployed (line 59). In the market deployment logic (
Operator::_activate
) will revert due to division by zero, andoperate
will fail.Once this condition is met, the
operate
cannot be called andHeart::beat
cannot be called as well, since theHeart::beat
is callingOperator::opearate
under the hood. As the result the price can never be updated. But other codes who uses the price information will not know that the price information is stale. If the upper wall is active and still have the capacity, one can swap from the upper wall using the stale information, which might cause some loss of funds.Cause
The main cause is that the
RANGE::setSpreads
function fails to check forwallSpread_ == 10000
. If the setter does not allow the wallSpread to be 100%, the price of the lower wall will not go to zero.In the
RANGE::updatePrices
, the price of lower wall will be zero if the wallSpread is 100%. If the price of lower wall is zero, theOperator::_activate
will fail for the lower cushion.Tools Used
foundry
Recommended Mitigation Steps
Mitigation suggestion: line 245. Forbid wallSpread to be 100%.