But in stabilize, priceTarget is always actual price target of maltDataLab regardless of stabilizeToPeg.
And it decides selling malt or doing auction by the priceTarget. So when stabilizeToPeg is true, priceTarget (= actual price target) can be different from maltDataLab.priceTarget() in most cases, and it can cause wrong decision of selling or starting auction after that.
Lines of code
https://github.com/code-423n4/2023-02-malt/blob/main/contracts/StabilityPod/StabilizerNode.sol#L178-L182 https://github.com/code-423n4/2023-02-malt/blob/main/contracts/StabilityPod/StabilizerNode.sol#L294-L298 https://github.com/code-423n4/2023-02-malt/blob/main/contracts/StabilityPod/StabilizerNode.sol#L188
Vulnerability details
Impact
priceTarget
is inconsistent inStabilizerNode.stabilize
sostabilize
can do auction instead of selling malt and vice versa.Proof of Concept
In
StabilizerNode.stabilize
, there is an early check using_shouldAdjustSupply
function.In
_shouldAdjustSupply
,priceTarget
is calculated bystabilizeToPeg
and then check ifexchangeRate
is outside of some margin ofpriceTarget
.But in
stabilize
,priceTarget
is always actual price target ofmaltDataLab
regardless ofstabilizeToPeg
. And it decides selling malt or doing auction by thepriceTarget
. So whenstabilizeToPeg
is true,priceTarget
(= actual price target) can be different frommaltDataLab.priceTarget()
in most cases, and it can cause wrong decision of selling or starting auction after that.So when
stabilizeToPeg
is true,stabilize
can do auction instead of selling malt, or vice versa.Tools Used
Manual Review
Recommended Mitigation Steps
Use same logic as
_shouldAdjustSupply
forpriceTarget
.priceTarget
should bemaltDataLab.priceTarget()
instabilize
whenstabilizeToPeg
is true.