MovingAverage.setSampleMemory()
may broke MovingAverage, making the value of exchangeRate
in StabilizerNode.stabilize()
being extremely wrong
#313
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/MovingAverage.sol#L424-L442
In the current implementation, when
sampleMemory
is updated, the samples index will be malposition, makinggetValueWithLookback()
get the wrong samples, so that returns the wrong value.PoC
10
movingAverage.update(1e18)
being called for 120 timesmovingAverage.setSampleMemory(118)
and set sampleMemory to118
The current
movingAverage.getValueWithLookback(sampleLength * 10)
returns0.00000203312 e18
, while it's expeceted to be1e18
After
setSampleMemory()
,getValueWithLookback()
may also return0
or revert FullMath: FULLDIV_OVERFLOW at L134.Recommendation
Consider removing
setSampleMemory
function.The text was updated successfully, but these errors were encountered: