DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: low
Invalid

Lack of Zero-Price Validation for Chainlink Oracle Data in PerpetualVault

Details:
The PerpetualVault contract relies on external price data (e.g., from Chainlink) to compute critical parameters such as order sizes and collateral requirements. However, there is no check to ensure that the reported price is non-zero. In the event of a significant malfunction or misconfiguration on the Chainlink node network, the oracle could return a zero price. This would lead to erroneous computations in functions like _createIncreasePosition, potentially resulting in zero or miscalculated order sizes, thereby disrupting normal operations.

Root Cause:
The contract does not validate the integrity of the fetched price data by checking whether the reported price is zero. This omission leaves the system vulnerable to miscalculations if the oracle data is faulty.

Impact:

  • Calculation Errors: A zero price may cause critical computations, such as the size delta for increasing a position, to yield incorrect or zero values, leading to ineffective or failed orders.

  • Operational Disruption: Miscalculations in order sizing and fee computations could disrupt trading operations, prevent successful deposits or withdrawals, or even halt the contract’s functionality.

  • User Risk: Although dependent on an external oracle malfunction (a lower-risk event), users could face unexpected behavior or financial loss if orders do not execute as planned.

Recommendation:

  • Input Validation: Implement checks in functions that utilize oracle price data to ensure that the price is non-zero before proceeding with any calculations.

  • Revert on Faulty Data: If a zero price is detected, revert the transaction with a clear error message to prevent execution with invalid data.

  • Redundant Price Source: It is good practice to integrate a redundant source of price for comparison and backup. This approach can help verify the accuracy of the primary oracle data and serve as a fallback in case the primary source returns an unexpected zero value.

  • Fallback Mechanism (Optional): Consider adding a fallback mechanism or alternative price source to maintain system reliability when the primary oracle fails or returns invalid data.

Proof of Concept:

  1. A misconfiguration or malfunction in the Chainlink node network causes the oracle to return a zero price for the short token.

  2. The PerpetualVault contract calls _createIncreasePosition, which calculates:

    • sizeDelta = prices.shortTokenPrice.max * amountIn * leverage / BASIS_POINTS_DIVISOR

    • With prices.shortTokenPrice.max being zero, sizeDelta becomes zero.

  3. An order is created with a sizeDelta of zero, leading to an ineffective position increase or order failure, thereby disrupting normal trading operations.

Incorporating these validations and redundancy measures will help ensure that only valid, non-zero price data is used in critical computations, reducing the risk of operational disruptions.

Updates

Lead Judging Commences

n0kto Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
n0kto Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.