The contract's Chainlink Oracle integration, specifically in how it handles price deviations and the associated maxDeviation
parameter, presents potential pitfalls. Inaccurate comments and a lack of specific checks could create operational vulnerabilities or misunderstandings, especially in scenarios where token prices exhibit little to no change.
Ambiguous Commenting: The maxDeviation
parameter within the addTokenMaxDeviation
function is commented as representing a deviation "in seconds". However, in the context of the _badPriceDeviation
function, it's clear that maxDeviation
pertains to price percentages. This discrepancy can lead to misinterpretations and incorrect configurations.
Unnecessary Check: The addTokenMaxDeviation
function has a superfluous check for maxDeviation < 0
. Given that maxDeviation
is a uint256
, it inherently cannot be negative. This redundancy might cause confusion.
Zero Deviation Vulnerability: In scenarios where currentResponse.answer
matches prevResponse.answer
, the deviation calculation is zero. This is particularly plausible with stable tokens (e.g., USDC), which might experience minimal price fluctuations. Such a scenario might bypass the intended deviation checks.
If the contract's administrator misunderstands or misconfigures the maxDeviation
parameter, the _badPriceDeviation
function might not operate as intended. This can lead to the contract either overlooking genuine price anomalies or falsely identifying regular price changes as anomalies.
Manual Code Analysis
Revise Commenting: Update the comment associated with the maxDeviation
parameter in the addTokenMaxDeviation
function to reflect its true purpose.
Eliminate Redundancy: Remove the unnecessary check if (maxDeviation < 0)
from the addTokenMaxDeviation
function.
Handle Zero Deviation: Introduce mechanisms to address zero deviation scenarios, especially for stable tokens.
Refine maxDeviation Input Validation: Enhance the addTokenMaxDeviation
function with input validation to ensure that the maxDeviation
value falls within a logical and safe range.
Documentation: It's crucial to maintain detailed documentation explaining the role and implications of the maxDeviation
parameter. This can prevent misconfigurations and clarify its operational significance.
Redundant check on maxDelay and/or maxDeviation in ARBOracle
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.