User may not receive the full amount of IL compensation
The Vader protocol's impermanent loss compensation function caps the payout at the reserve balance without letting the user specify a minimum acceptable amount. An attacker could exploit this via MEV to cause the user to receive less compensation than expected.
Submitted by jonah1005
Impact
The user would not get full IL compensation if there’s not enough funds in the reserve. VaderReserve.sol#L76-L91
VaderReserve.sol#L85
uint256 actualAmount = _min(reserve(), amount);
While this is reasonable, users should be able to specify the minimum received amount in the transaction. Otherwise, it’s vulnerable to some kind of MEV attack.
I consider this is a medium-risk issue.
Proof of Concept
The user can not specify a minimum IL compensation in the router. VaderRouter.sol#L169-L207
The user may not receive the full amount of compensation. VaderReserve.sol#L76-L91
Tools Used
None
Recommended Mitigation Steps
Users should be able to protect themselves when burning lp.
Some possible fixes:
- Return the actual amount this line
reserve.reimburseImpermanentLoss(msg.sender, coveredloss); - Checks whether there’s slippage. Revert if the user doesn’t receive the full amount.
We can add a new parameter in the function.
require(actualCompensation > minimumCompensation);
Or we can check the amountAMin after receiving the compensation. ( assume tokenA is native token)
require(amountA +actualCompensation > amountAMin);
This is intended functionality of the protocol to account for rounding errors and is a principle similar to SushiSwap’s MasterChef contract.
The sponsor acknowledges the issue.
@alcueca They are never meant however it should still be possible to do so. With Uniswap V2, it is possible to interact with the contracts directly however doing so (without using a smart contract) will result in the same vulnerabilities as described in the issue. This is not intended usage and as such does not constitute an issue unless it is implied that the Uniswap V2 implementation is incorrect. Intended functionality of the protocol cannot constitute a risk issue. This has been classified as a medium risk issue but it follows the standardized conventions of implementations like Sushiswap which are live.
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 compensation function caps the payout at the reserve balance without allowing the caller to specify a minimum acceptable amount, leaving the transaction open to MEV manipulation.
Impact
A user could receive less than the full impermanent loss compensation if the reserve lacks sufficient funds, and an MEV attacker could exploit this to reduce the payout.
What the attacker needed
User burns LP tokens to claim IL compensation; reserve has insufficient funds; MEV attacker can manipulate reserve balance
The fix
The function should allow the user to specify a minimum compensation amount and revert if the actual compensation is below it, or return the actual amount so the caller can check slippage.
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.
When you provide liquidity to a decentralised exchange, you can suffer 'impermanent loss' if the price of your deposited tokens changes. Vader promises to compensate for this loss, but the code only pays out what is available in a reserve pool. If the pool is low, you get less than you were owed, and you have no way to say 'don't process this transaction if I won't get at least X'. An attacker who can see your transaction before it is confirmed (MEV) might drain the reserve first so you receive very little.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.