Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping Price Ranges in RWADynamicOracle Contract #25

Closed
code423n4 opened this issue Sep 2, 2023 · 4 comments
Closed

Overlapping Price Ranges in RWADynamicOracle Contract #25

code423n4 opened this issue Sep 2, 2023 · 4 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working low quality report This report is of especially low quality primary issue Highest quality submission among a set of duplicates unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

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

Vulnerability details

Impact

The RWADynamicOracle contract allows for the setting of different price ranges with different daily interest rates. If the price ranges overlap due to incorrect validations, it can lead to incorrect price calculations, potentially affecting any system or protocol that relies on this oracle for pricing information.

Proof of Concept

In the overrideRange function, there's a potential issue with how the new start and end times for a range are validated against existing ranges.
Line #212: Here, the newStart should be strictly greater than the end time of the previous range. The current check is newStart < ranges[indexToModify - 1].end but it should be newStart > ranges[indexToModify - 1].end.
Line #214: Here, the newEnd should be strictly less than the start time of the next range. The current check is newEnd > ranges[indexToModify + 1].start but it should be newEnd < ranges[indexToModify + 1].start.

Tools Used

Manual Code Review

Recommended Mitigation Steps

Update the overrideRange function to ensure that the new start and end times for a range do not overlap with existing ranges.
Specifically, modify the checks on lines 212 and 214 as mentioned in the Proof of Concept section.

Assessed type

Context

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Sep 2, 2023
code423n4 added a commit that referenced this issue Sep 2, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as primary issue

@c4-pre-sort c4-pre-sort added the primary issue Highest quality submission among a set of duplicates label Sep 7, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as low quality report

@c4-pre-sort c4-pre-sort added the low quality report This report is of especially low quality label Sep 7, 2023
@raymondfam
Copy link

raymondfam commented Sep 7, 2023

Your assumptions would be correct if the conditional statements were using require statement.

Additionally, per the readme:

We are aware that if a range is updated the prevRangeClosePrice for subsequent set ranges will be stale.

This was referenced Sep 7, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as unsatisfactory:
Invalid

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working low quality report This report is of especially low quality primary issue Highest quality submission among a set of duplicates unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants