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

Lack of Validation for GMX Price Data in PerpetualVault's run() and runNextAction() Functions

Summary:

The run() and runNextAction() functions do not validate the GMX price data (prices argument) PerpetualVault's before using it, which could lead to the execution of actions based on invalid or malformed price data.

Severity: Medium
Impact: Medium
Likelihood: Medium

Affected Line of Code:

https://github.com/CodeHawks-Contests/2025-02-gamma/blob/main/contracts/PerpetualVault.sol#L290-L341

https://github.com/CodeHawks-Contests/2025-02-gamma/blob/main/contracts/PerpetualVault.sol#L350-L409

  1. run(): Lines that utilize the prices parameter without validation.

  2. runNextAction(): Lines where prices are passed without checks.


Finding Description:

The functions run() and runNextAction() rely on price data (prices) from the GMX API, but there is no validation to ensure that the price data is valid. This breaks the security guarantee that the contract operates with accurate and trustworthy data.

  • Security Guarantee Breaks: The lack of validation on prices allows invalid data to be used in critical operations, such as opening/closing positions, swapping tokens, and managing liquidity. Malicious users or external errors could provide invalid price data, causing incorrect contract behavior.

  • Malicious Input Propagation: A malicious or faulty price feed could propagate through the system when interacting with these functions, leading to incorrect transactions or contract behavior. For example, if a malicious actor can influence the price data, they could manipulate the position opening/closing logic, causing a loss of funds.


Impact Explanation:

  • Severity: Medium

  • Impact: The impact is significant in that invalid price data can cause incorrect decisions to be made in the contract, such as opening positions at wrong prices or executing swaps with incorrect values. This can lead to unexpected behavior, including potential loss of funds.

    The issue doesn't automatically cause failure, but it leaves the system vulnerable to faulty price inputs, which could lead to significant financial damage if exploited in a real-world environment.

Likelihood Explanation:

  • Likelihood: Medium

  • The likelihood of encountering invalid price data depends on the reliability of the GMX API and the robustness of the contract's price data handling. While this may not happen in normal operation, the absence of validation makes it easier for malicious actors or system failures to introduce invalid prices that could propagate through the contract.


Proof of Concept:

  1. NIL. as it is clearly visible


Recommendation:

  • Fix: Add a validation check to ensure that prices contain valid data before proceeding with any actions. This can be done by verifying that the prices are greater than zero or within a reasonable range.

require(prices.price1 > 0 && prices.price2 > 0 && prices.price3 > 0, "Invalid GMX price data");
  • This check should be added at the beginning of both the run() and runNextAction() functions to ensure that only valid price data is used in critical contract actions.

Updates

Lead Judging Commences

n0kto Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Admin is trusted / Malicious keepers

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point. Keepers are added by the admin, there is no "malicious keeper" and if there is a problem in those keepers, that's out of scope. ReadMe and known issues states: " * System relies heavily on keeper for executing trades * Single keeper point of failure if not properly distributed * Malicious keeper could potentially front-run or delay transactions * Assume that Keeper will always have enough gas to execute transactions. There is a pay execution fee function, but the assumption should be that there's more than enough gas to cover transaction failures, retries, etc * There are two spot swap functionalies: (1) using GMX swap and (2) using Paraswap. We can assume that any swap failure will be retried until success. " " * Heavy dependency on GMX protocol functioning correctly * Owner can update GMX-related addresses * Changes in GMX protocol could impact system operations * We can assume that the GMX keeper won't misbehave, delay, or go offline. " "Issues related to GMX Keepers being DOS'd or losing functionality would be considered invalid."

Suppositions

There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.

Support

FAQs

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