Under current price implementation, the last day for a range will always use the interest from next range instead of its own interest. #165
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-492
low quality report
This report is of especially low quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-09-ondo/blob/47d34d6d4a5303af5f46e907ac2292e6a7745f6c/contracts/rwaOracles/RWADynamicOracle.sol#L151-L171
https://github.com/code-423n4/2023-09-ondo/blob/47d34d6d4a5303af5f46e907ac2292e6a7745f6c/contracts/rwaOracles/RWADynamicOracle.sol#L262-L274
Vulnerability details
Impact
Under current price implementation, the last day for a range will always use the interest from next range instead of its own interest.
Proof of Concept
In setRange() function, it will set prevClosePrice as below.
This will always set the prevClosePrice to the price of one day before range.end. For example, if the periodStart is July 31, 8 PM, and periodEnd is August 31, 8 PM, when we set next range as August 31, 8 PM to September 30, 8 PM, the prevClosePrice will be the price at August 30, 8 PM. Now if we set the timestamp to August 31, 8 PM, the daily IR for August 30, 8 PM to August 31, 8 PM will be the IR from August 31, 8 PM to September 30, 8 PM, this is incorrect since August 30 to August 31 is still within the first range.
A simple POC can explain, add it to RWADynamicOracle.t.sol
Tools Used
Manual Review, Foundry
Recommended Mitigation Steps
The issue here is due to using a prevClosePrice which is calculated as range initial price / dailyIR, I am not sure the reason about this since I think we can directly use that initial price as a start price.
Assessed type
Other
The text was updated successfully, but these errors were encountered: