Open code423n4 opened 1 year ago
Duplicated by #13
Picodes marked the issue as primary issue
0xScotch marked the issue as sponsor confirmed
We actually do want the tx to revert when latestSample < priceTarget
as that means the most recent sample in the price average feed is below peg but we are in the above peg stabilization flow in the code. However, we do not want the revert to be subtraction overflow as that looks like something went wrong. So we should handle with an explicit error.
Picodes marked the issue as satisfactory
Picodes marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-02-malt/blob/main/contracts/StabilityPod/StabilizerNode.sol#L188 https://github.com/code-423n4/2023-02-malt/blob/main/contracts/StabilityPod/StabilizerNode.sol#L201-L203
Vulnerability details
Impact
StabilizerNode.stabilize
will revert whenlatestSample < priceTarget
.Proof of Concept
In StabilizerNode.stabilize, when
exchangeRate > priceTarget
and_msgSender
is not an admin and not whitelisted, it assertslivePrice > minThreshold
. AndminThreshold
is calculated as follows:This code snippet assumes that
latestSample >= priceTarget
. AlthoughexchangeRate > priceTarget
,exchangeRate
is the malt average price duringpriceAveragePeriod
. ButlatestSample
is one of those malt prices. SolatestSample
can be less thanexchangeRate
andpriceTarget
, sostabilize
will revert in this case.Tools Used
Manual Review
Recommended Mitigation Steps
Use
minThreshold = latestSample + (((priceTarget - latestSample) * sampleSlippageBps) / 10000)
whenpriceTarget > latestSample
.