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

Updating closed ranges with overrideRange() causes incorrect prevRangeClosePrice. #380

Closed
c4-submissions opened this issue Sep 7, 2023 · 5 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-25 low quality report This report is of especially low quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-submissions
Copy link
Contributor

Lines of code

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

Vulnerability details

Impact

  • Incorrect starting prices for ranges
  • Incorrect historical price derivations
  • Loss of accurate price data history

Proof of Concept

updating closed ranges with overrideRange() can cause an incorrect prevRangeClosePrice value. Here is a more detailed explanation:

The prevRangeClosePrice is intended to be the derived price from the previous range at the end of that range. This value is then used as the starting price for the next range.

The issue occurs if you call overrideRange() on a closed range. For example:

Range 1:
Start: 1000
End: 2000
prevRangeClosePrice: 10

Range 2:
Start: 2000
End: 3000
prevRangeClosePrice: 20

If you then call overrideRange() to modify Range 1 after it is already closed:

overrideRange(0, 1500, 2500, 5%, 30)

This will update Range 1 but leave Range 2's prevRangeClosePrice as 20. When in reality, based on the new Range 1 values, the prevRangeClosePrice for Range 2 should be 25.

So Range 2's starting price is now incorrect based on the previous range.

This happens because overrideRange() just overwrites the closed range values without recalculating subsequent ranges.

Tools Used

Manual

Recommended Mitigation Steps

Recalculate all subsequent range's prevRangeClosePrices if a closed range is overridden

Assessed type

Other

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

From readme:

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

@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 8, 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 8, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #25

@c4-pre-sort c4-pre-sort added duplicate-25 and removed primary issue Highest quality submission among a set of duplicates labels Sep 10, 2023
@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Sep 19, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as unsatisfactory:
Invalid

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 duplicate-25 low quality report This report is of especially low quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants