The verifyOffchainPrice() function in the StabilityConfiguration contract relies on block.timestamp to determine the validity of a Chainlink price report. However, due to potential network delays or minor discrepancies in timestamp synchronization across nodes, valid price reports may be incorrectly marked as expired. This can cause the function to revert, leading to potential service disruptions and price oracle failures.
The following code snippet demonstrates the issue:
Issue here is that:
The function checks if the current block timestamp (block.timestamp) exceeds the sum of validFromTimestamp and maxVerificationDelay. If there is a minor delay in the verification process due to network congestion or latency, valid price reports may be rejected. This can cause unnecessary reverts, disrupting price feeds and causing failures in downstream contracts.
To demonstrate the vulnerability, let's simulate a scenario in Foundry where:
The contract has a maxVerificationDelay of 300 seconds (5 minutes).
A valid price report is submitted with a validFromTimestamp that is 299 seconds old.
A small delay in transaction execution causes block.timestamp to exceed the maxVerificationDelay, making the report erroneously invalid.
Output:
Price verification can fail unpredictably, disrupting oracle-dependent operations.
If price feeds are rejected due to small network delays, it could trigger false liquidations or prevent legitimate ones.
Manual review.
A buffer should be added to the verification check to account for minor delays. This can be achieved by increasing the allowed expiration time by a small margin (e.g., 15 seconds):
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.