Closed sherlock-admin3 closed 7 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
its trusted to provide accurate data.
Invalid, this falls under the following known issue:
- Oracle (Pyth) is expected to accurately report the price of market
Even if a 0 price is returned, it is assume that it is the accurate market price for the asset at that point of time. It also means a depeg has occured, but this issue fails to provide an adequate explanation.
The sponsor acknowledges that zero is a valid price, and the change may cause liquidations to be impossible in such cases, but points out that crypto prices are unlikely to be zero.
0xumarkhatab
medium
Protocol Implementation accepts 0 price from Pyth network which can cause Disruption in core functionalities
Summary
Currently, core functions of protocol like
quoteOptoin , liquidate , transferMarginToFund,Order execution
depends on the fetched price of the asset from Pyth network. However, in the current implementation, the protocol does not prevent zero price and these functionalities can be badly affected.Protocol team member
bchen3
has confirmed that even though they trust the Pyth network , this scenario is considerable to mitigate.Vulnerability Detail
The getPrice function gets the price from Pyth network which is a source of reliable data feeds.
This function handles things elegantly however , current implementation does not prevent 0 price. According to Pythnet - How to use Price Feeds :
Pyth network acknowledges that stale prices can be delivered for an asset in some scenarios. The likelihood is low but the impact on liquidation , quoteOption ,transferMarginToFund, Order execution can be drastic . It can either make loss of funds for users or just bricking the functionality of the system based on different scenarios
Impact
liquidation , quoteOption ,transferMarginToFund, Order execution
Code Snippet
https://github.com/sherlock-audit/2024-02-perpetual/blob/main/perp-contract-v3/src/oracle/pythOracleAdapter/PythOracleAdapter.sol#L80-L89
Tool used
Manual Review
Recommendation
Add non-zero price check in getPrice
You can also check this in
_convertToUint256
as