The _getData function in the MultiHopOracle contract contains critical vulnerabilities that can lead to arithmetic overflow when processing extreme oracle data values. These vulnerabilities arise from the lack of safeguards against large intermediate results during multiplication and inversion operations. Specifically, the use of excessively large scaling factors, such as 10**36 and 10**18, combined with potentially small or large oracle data values, creates scenarios where intermediate calculations exceed the range of int216.
The first oracle's result is inverted using:
Oracle A data: 10**-30 (price of Token A / Token B).
Calculation:
Issue:
10**66 exceeds the maximum range of int216, which is approximately 10**64. This results in an overflow error, halting the execution of the function.
The subsequent oracle calculations multiply data by the next oracle's result before dividing by the precision factor 10**18:
Initial data: 10**60 (already close to int216 limits).
Oracle B data: 10**10 (price of Token B / Token C).
Calculation:
Issue:
The intermediate result 10**78 exceeds the int216 range, causing an overflow before the division can occur.
Excessive Scaling Factors: Using 10**36 for inversion and 10**18 for precision unnecessarily inflates intermediate values.
No Range Checks: The function does not verify that intermediate calculations remain within the bounds of int216.
Denial of Service: Overflow causes the contract to revert, preventing critical price data from being retrieved.
Data Integrity Risks: Even if not exploited maliciously, genuine oracle data could cause failures, impacting dependent systems.
Manual Code Review
Test simulation with real life figures
Replace 10**36 with smaller scaling factors or use fixed-point arithmetic libraries:
Add checks to ensure intermediate values remain within safe bounds:
By implementing these recommendations, the MultiHopOracle contract can handle extreme oracle values more robustly, ensuring reliable and secure price data computation.
Likelihood: Informational/Very Low, admin should use a price feed with 18 decimals and this feed should compare a assets with a very small value and an asset with a biggest amount to have the smallest price possible. Admin wouldn't do that intentionally, but one token could collapse, and with multiple hop, it increases a bit the probability. Impact: High, complete loss of precision. Probability near 0 but not 0: deserve a Low
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.