The ChainlinkARBOracle contract is designed to process and validate Chainlink oracle responses. However, its current implementation only checks if the response is zero and omits potential negative values. This oversight, attributed to the use of the == operator instead of <=, can introduce inaccuracies in the deviation calculation, potentially affecting key functions like consult and consultIn18Decimals. Since chainlink price feed may potentially return negative values as stated here
Within the ChainlinkARBOracle contract, the _badChainlinkResponse function is tasked with validating Chainlink oracle responses:
This approach exclusively identifies zero responses, neglecting possible negative outcomes. The implications of this narrow check are most evident in functions like _badPriceDeviation. Since the value answer is an int256 variable it might return a negative value as stated here if the price of that token drops drastically. For example, when oil futures dropped below zero.
Deviation Miscalculations: In scenarios where currentResponse.answer holds a negative value contrasting a positive prevResponse.answer, For instance, with a currentResponse.answer of -5 and a prevResponse.answer of 10, the deviation calculation in _badPriceDeviation will not yield the intended results, leading to potential miscalculations.The resulting computation may not align with the contract's expected behavior.
Inaccurate Function Outputs: The outputs of functions, specifically consult, could be compromised by such miscalculations.This might return negative price data and incorrect decimals.
Risk of Function Reverts: Functions like consultIn18Decimals, which rely on these verifications, may inadvertently revert if presented with unexpected negative price data. This poses operational risks for the contract and any other contract that are calling this function due to the fact that this function will revert when a negative value is provided as function toUint256() from SafeCast reverts it to prevent underflow/overflow.
Manual Code Review
To bolster the integrity of the contract, it's recommended to modify the validation in the _badChainlinkResponse function to encompass all non-positive responses:
By implementing this refined check, the ChainlinkARBOracle contract can more accurately and consistently handle Chainlink oracle data, reducing the potential risks stemming from unanticipated price feed values.
Very low likelihood -> evaluate the severity to 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.