setEpochDuration() breaks the user's expected exchangeRate #83
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
duplicate-205
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-01-ondo/blob/f3426e5b6b4561e09460b2e6471eb694efdd6c70/contracts/cash/CashManager.sol#L546-L552
Vulnerability details
Impact
Extended epoch time, resulting in exchangeRate changes that affect user revenue
Proof of Concept
MANAGER_ADMIN can modify epochDuration with setEpochDuration()
epochDuration is an important factor in the calculation of whether to enter a new epoch
However, setEpochDuration() does not first perform an updateEpoch (if it needs to be currently satisfied to enter a new epoch, it enters a new epoch)
As a result, it may not be possible to switch to the new epoch because the epochDuration has grown, and the old epoch is still used.
As each epoch will have its own exchangeRate, the user has already estimated the exchangeRate before the end of the epoch, so the requestMint() is performed.
Since setEpochDuration changed the epochDuration, the exchangeRate changed. when exchangeRate changes ,maybe affect user revenue
So it is recommended to calculate the old epochDuration for the elapsed time to get the correct exchangeRate
Tools Used
Recommended Mitigation Steps
add updateEpoch
The text was updated successfully, but these errors were encountered: