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

Improper Price Validation in KeeperProxy Contract

Location

KeeperProxy.sol -> Line 155

Description

In the KeeperProxy contract, the _validatePrice function is supposed to check that market prices are within acceptable limits before any keeper actions take place. However, there's a mistake: it verifies the price for the long token using the index token’s price feed (prices.indexTokenPrice) instead of the dedicated long token price feed (prices.longTokenPrice).

  • Current Assumption:
    Right now, the system assumes that the index token and the long token are the same, so this bug might not cause issues immediately. But if this assumption ever changes, orders could be executed based on manipulated prices, potentially resulting in losses—especially in leveraged trading environments.

  • Future Risk:
    If the protocol expands to support markets where the index and long tokens differ, this misconfiguration could allow an attacker to manipulate price validations by influencing the index token’s price, leading to erroneous order execution.

  • Financial Impact:

    This error could have a financial impact and significant reputational loss and losses for users

Impact

Here is the code now:

function _validatePrice(address perpVault, MarketPrices memory prices) internal view {
// ... (market data retrieval and sequencer check)
_check(marketData.indexToken, prices.indexTokenPrice.min);
_check(marketData.indexToken, prices.indexTokenPrice.max);
// Vulnerability: longToken price validated using indexTokenPrice
_check(marketData.longToken, prices.indexTokenPrice.min);
_check(marketData.longToken, prices.indexTokenPrice.max);
_check(marketData.shortToken, prices.shortTokenPrice.min);
_check(marketData.shortToken, prices.shortTokenPrice.max);
}
  • Order Execution Risk: Orders involving long tokens could be executed based on manipulated or incorrect price data, leading to potential financial losses in leveraged trading scenarios.

  • Exploitation Potential: An attacker with influence over the index token’s price feed might cause valid orders to be rejected or processed under adverse pricing conditions.

  • Future Vulnerability: As the protocol scales or supports a broader range of markets, the misconfiguration could expose the system to significant risk.

Tools Used

Forge/Foundry

Recommendations

_check(marketData.longToken, prices.longTokenPrice.min);
_check(marketData.longToken, prices.longTokenPrice.max);
Updates

Lead Judging Commences

n0kto Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding_validatePrice_no_check_for_longTokenPrice

Likelihood: None/Very Low, everytime the keeper send a price via run/runNextAction (sent by the Gamma keeper). Impact: Medium/High, does not check the longTokenPrice, it could go out of range. Keep in mind indexToken == longToken, an error from the keeper could be considered informational.

Support

FAQs

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