https://github.com/Cyfrin/2024-07-zaros/blob/main/src/external/chainlink/keepers/liquidation/LiquidationKeeper.sol#L61-L65
Within the LiquidationKeeper.sol
contract, the checkUpkeep
function can return upkeepNeeded
as false if there aren't a certain number of liquidatable accounts. This can lead to a scenario where a user can fill a market order while liquidations pile up, resulting in market manipulation and significant financial losses.
The checkUpkeep
function in the LiquidationKeeper.sol
contract checks if there are liquidatable accounts within a specified range. If the number of liquidatable accounts does not exceed a certain threshold, upkeepNeeded
is set to false, and the function returns without triggering any liquidations. This predictability allows an attacker to fill a market order just before the liquidations are triggered, securing a favorable market position and profiting from the subsequent liquidation events.
This vulnerability can be exploited by advanced traders who can predict when liquidations will be delayed due to the insufficient number of liquidatable accounts, allowing them to manipulate the market:
Arbitrage Opportunities: Attackers can exploit the predictable delay in liquidations to place market orders at favorable prices, leading to arbitrage opportunities that can drain liquidity and destabilize the market.
Market Manipulation: Malicious traders can front-run the liquidation process by placing orders before liquidations are executed, benefiting from the expected market movements caused by liquidations.
Increased Volatility: Predictable delays in liquidation can lead to artificial price swings, causing increased volatility and potential long-term market imbalance.
Loss of Market Integrity: The ability to predict and exploit the timing of liquidations can erode trust in the market, leading to decreased participation and liquidity.
Monitor Liquidatable Accounts: An attacker identifies accounts that are close to liquidation and monitors the checkUpkeep
function's behavior.
Place Market Order: The attacker places a market order when they predict that liquidations will not be triggered immediately.
Profit from Liquidation: The attacker benefits from the price movement caused by the subsequent liquidation events.
To illustrate the potential financial impact, consider the following hypothetical scenario:
A large number of accounts are close to liquidation, but the number does not exceed the threshold required to trigger upkeepNeeded
.
The attacker places a market sell order just before the expected liquidations, securing a higher price.
After the liquidation eventually occurs, the attacker buys back the asset at a lower price, profiting from the price difference.
If the market capitalization is large, even a small percentage movement due to liquidation manipulation can lead to substantial financial gains for the attacker. For example, if the market has a total value of $500 million and the manipulation causes a 2% price change, the financial impact could be $10 million.
Manual Review
Handle liquidations as they come instead of waiting for batch processing.
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.