Operator::setReserveFactor doesn’t check if bond market should be changed
The setReserveFactor function updates the reserve factor without regenerating the market sides, so the capacity thresholds used to decide whether a bond market wall should be down or closed become stale. An attacker or guardian could leave a side operating with outdated capacity limits until a manual regeneration occurs.
Originally disclosed on Code4rena
Submitted by rvierdiiev
Operator::setReserveFactor sets new reserveFactor value. This parameter is used in fullCapacity function to calculate how much capacity is available by high/low side. Then calculated capacity is used by Range module inside regenerate function to set the threshold of capacity for both sides of market. Then in Range::updateCapacity function this threshold is checked to understand if the wall should be down and the bond market should be closed.
Changing this value means that the capacity of sides has changed and the sides should be regenarated to include this changes.
Proof of Concept
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Operator.sol#L548 https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Operator.sol#L711 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L133 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L145 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L185 https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Operator.sol#L780
Recommended Mitigation Steps
Call this after the param updating.
_regenerate(true); _regenerate(false;
Oighty (Olympus) confirmed and commented:
Forcing a regeneration when the reserveFactor is updated could cause unintended regeneration if a wall is currently down. A better approach may be to conditionally regenerate each side if they are active.
Oighty (Olympus) acknowledged and commented:
After discussing with the team more, we are going to leave this as-is. It is more flexible to not regenerate the side in this function. With the current implementation, the guardian can determine if the change should go into effect on the next regen, or if it should happen immediately. To enable immediately, they can manually call
regenerate.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the setter updates the reserve factor but does not trigger regeneration of the range sides, leaving capacity thresholds stale.
Impact
The bond market could remain active or inactive with outdated capacity thresholds until someone manually calls regenerate, which may allow trading under stale limits.
What the attacker needed
Guardian or privileged caller updates reserve factor
The fix
The team decided to leave it as-is, arguing the guardian can manually call regenerate when an immediate change is wanted.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract stores a setting that controls how much of a market can be active. When that setting changes, the contract should recalculate the market limits, but it does not, so the old limits stay in place. This can leave a market open or closed when it should be the opposite.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.