The KeeperProxy contract's _check()
function makes a critical assumption about Chainlink price feed decimals that contradicts industry standards. The code assumes all Chainlink feeds use 8 decimals, but this isn't universally true. This mismatch could lead to incorrect price validations, potentially allowing positions to be opened or closed at unfair prices.
This vulnerability directly impacts the protocol's core invariant: "Depositor Share Value Preservation". As stated in the documentation, "The value of a depositor's shares should never decrease due to the actions of other depositors." However, if prices are validated incorrectly, this invariant could be violated as users could enter or exit positions at incorrect prices.
In KeeperProxy.sol, the _check()
function contains this problematic code:
The comment // Chainlink price decimals is always 8
is incorrect. Let's look at a real scenario:
Consider the ETH/USD price feed on Arbitrum (mentioned in project documentation as a supported chain). If a user deposits ETH and the keeper tries to validate the price:
The token decimals (ETH) = 18
The calculation becomes: decimals = 30 - 18 = 12
The price division: price / 10 ** (12 - 8) = price / 10 ** 4
However, if the Chainlink feed uses 18 decimals instead of the assumed 8, this creates a 10^14 magnitude error in the price comparison. A price that should be rejected could pass validation or vice versa.
This is particularly concerning given the protocol's stated use case: "The Perpetual Vault Protocol is a DeFi system that enables users to engage in leveraged trading on the GMX decentralized exchange." Incorrect price validations in a leveraged trading system could lead to significant losses.
Here's a practical example:
Manual Review
Foundry
Modify the _check()
function to dynamically fetch the feed's decimals:
This solution ensures correct price validation regardless of the feed's decimal places, maintaining the protocol's invariants and protecting user funds.
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.
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."
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.
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."
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.