code-423n4 / 2023-09-ondo-findings

7 stars 5 forks source link

Potential Function Stuck Due to Future Timestamp in range.start #525

Closed c4-submissions closed 1 year ago

c4-submissions commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-09-ondo/blob/47d34d6d4a5303af5f46e907ac2292e6a7745f6c/contracts/rwaOracles/RWADynamicOracle.sol#L79

Vulnerability details

If the range.start is set to a future timestamp, and none of the other ranges satisfy the condition within the loop, the getPrice function would exit without returning any value. This is problematic as users and dependent functions expect a price value to be returned.

Impact

If getPrice is called and doesn't return a value due to the mentioned scenario, dependent operations that rely on the returned price could fail or behave unexpectedly. It might cause confusion among users or contract operators, leading to potential reputational damage and trust issues. Any operation dependent on the price data could get stuck or halt, affecting the normal functioning of the system.

Proof of Concept

Alice deploys the contract and sets a range.start to a future timestamp. Bob interacts with the contract, calling the getPrice function. Since range.start is in the future, the condition is not satisfied, and the loop doesn't return any value. Bob is left in confusion as he doesn't receive a price, and any operations he intended to perform based on that price might fail or produce unexpected results.

Tools Used

Recommended Mitigation Steps

Add a default return value at the end of the function to ensure that getPrice always returns a value. Implement checks when setting the range to ensure that range.start is never set to a future timestamp. Consider adding more comprehensive tests to cover scenarios where ranges might have timestamps set in the future.

Assessed type

Error

c4-pre-sort commented 1 year ago

raymondfam marked the issue as duplicate of #451

c4-pre-sort commented 1 year ago

raymondfam marked the issue as sufficient quality report

c4-judge commented 1 year ago

kirk-baird marked the issue as satisfactory

c4-judge commented 1 year ago

kirk-baird changed the severity to QA (Quality Assurance)

c4-judge commented 1 year ago

kirk-baird marked the issue as grade-c