LPs of VaderPoolV2 can manipulate pool reserves to extract funds from the reserve.
The impermanent loss protection in VaderPoolV2 calculates losses based on current pool reserves, which an LP can manipulate by flashloaning and trading to artificially inflate their impermanent loss. This allows the LP to withdraw a large payout from the reserve while keeping their position value unchanged.
Originally disclosed on Code4rena
Submitted by TomFrenchBlockchain, also found by WatchPug
Impact
Impermanent loss protection can be exploited to drain the reserve.
Proof of Concept
In VaderPoolV2.burn we calculate the current losses that the LP has made to impermanent loss.
These losses are then refunded to the LP in VADER tokens from the reserve
This loss is calculated by the current reserves of the pool so if an LP can manipulate the pool’s reserves they can artificially engineer a huge amount of IL in order to qualify for a payout up to the size of their LP position.
The attack is then as follows.
- Be an LP for a reasonable period of time (IL protection scales linearly up to 100% after a year)
- Flashloan a huge amount of one of the pool’s assets.
- Trade against the pool with the flashloaned funds to unbalance it such that your LP position has huge IL.
- Remove your liquidity and receive compensation from the reserve for the IL you have engineered.
- Re-add your liquidity back to the pool.
- Trade against the pool to bring it back into balance.
The attacker now holds the majority of their flashloaned funds (minus slippage/swap fees) along with a large fraction of the value of their LP position in VADER paid out from the reserve. The value of their LP position is unchanged. Given a large enough LP position, the IL protection funds extracted from the reserve will exceed the funds lost to swap fees and the attacker will be able to repay their flashloan with a profit.
This is a high risk issue as after a year any large LP is incentivised and able to perform this attack.
Recommended Mitigation Steps
Use a manipulation resistant oracle for the relative prices of the pool’s assets (TWAP, etc.)
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the impermanent loss calculation relies on the pool's current reserves, which can be manipulated within a single transaction, instead of a manipulation-resistant price oracle.
Impact
An attacker could drain a significant portion of the reserve, potentially profiting if their LP position is large enough to outweigh swap fees and slippage.
What the attacker needed
Be a liquidity provider for a period; access to a flashloan; sufficiently large LP position
The fix
The impermanent loss calculation should use a manipulation-resistant oracle for the relative prices of the pool's assets, such as a TWAP.
How it was found
- Be an LP for a reasonable period of time (IL protection scales linearly up to 100% after a year)
- Flashloan a huge amount of one of the pool’s assets.
- Trade against the pool with the flashloaned funds to unbalance it such that your LP position has huge IL.
- Remove your liquidity and receive compensation from the reserve for the IL you have engineered.
- Re-add your liquidity back to the pool.
- Trade against the pool to bring it back into balance.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A liquidity provider (LP) puts tokens into a pool to earn fees. The protocol promised to refund any 'impermanent loss' (loss from price changes) using a reserve fund. But the loss is measured using the pool's current token balances, which an attacker can temporarily distort with a large flash loan (a loan repaid in the same transaction). The attacker can then claim a big refund while their actual position value stays the same.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.