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

Oracle Price Manipulation in KeeperProxy

Summary

The KeeperProxy contract relies on off-chain price feeds (dataFeed mapping) to validate prices before executing actions in the perpetual vault. However, the contract does not verify the integrity of these price feeds, making it vulnerable to price manipulation. If an attacker gains control over the Chainlink price feed or forces it to return stale or manipulated values, they could execute trades under unfair conditions.

Vulnerability Details

  • Function Affected: _validatePrice(), _check()

  • Root Cause:

    • The contract does not verify if the dataFeed source is manipulated or compromised.

    • The price update time (updatedAt) is only checked against maxTimeWindow, but this does not account for sudden price drops, flash loan manipulation, or oracle attacks.

    • The sequencer uptime check only ensures the oracle is running, not that the prices are valid or untampered.

PoC

Attackers can manipulate the price feed through:

  1. Compromising the Chainlink oracle (e.g., if an unauthorized price feed is registered).

  2. Manipulating liquidity on decentralized exchanges (DEXs) to influence TWAP or Chainlink's aggregated price.

  3. Submitting stale data to bypass recent price fluctuations.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "forge-std/Test.sol";
import "../KeeperProxy.sol";
import "../mocks/MockOracle.sol";
contract KeeperProxyTest is Test {
KeeperProxy keeperProxy;
MockOracle mockOracle;
address attacker = address(0xBEEF);
function setUp() public {
// Deploy KeeperProxy and Mock Oracle
keeperProxy = new KeeperProxy();
mockOracle = new MockOracle();
// Set attacker as the data feed provider
keeperProxy.setDataFeed(address(0xToken), address(mockOracle), 600, 50);
}
function testOraclePriceManipulation() public {
// Attacker sets a fake high price
mockOracle.setFakePrice(1_000_000e8, block.timestamp);
// Run validation
vm.prank(attacker);
keeperProxy.run(address(0xPerpVault), true, true, MarketPrices(1_000_000e8), new bytes // Expect that the manipulated price was used in execution
assertEq(keeperProxy.dataFeed(address(0xToken)), address(mockOracle));
}
}

Impact

  • Price validation can be bypassed, leading to fraudulent trades based on manipulated prices.

  • Loss of funds due to incorrect execution prices, which could be exploited for arbitrage or liquidation manipulation.

  • Potential flash loan exploitation, where an attacker temporarily inflates prices, executes an order, and then reverts the price before settlement.

Tools Used

Manual review, Foundry

Recommendations

  • Use Chainlink's latestRoundData() and verify that answeredInRound is recent and consistent.

  • Require multiple independent price sources (e.g., Chainlink + Uniswap TWAP).

  • Implement circuit breakers: If price deviation exceeds a threshold, block execution.

  • Check liquidity depth before relying on a single oracle price.

Updates

Lead Judging Commences

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

Informational or Gas

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.

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.

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

Informational or Gas

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.

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.