Skip to content
Business logic Audit finding Intermediate

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.

jonah1005 Follow

Originally disclosed on Code4rena

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:

  1. Return the actual amount this line reserve.reimburseImpermanentLoss(msg.sender, coveredloss);
  2. 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);

SamSteinGG (Vader) disputed:

This is intended functionality of the protocol to account for rounding errors and is a principle similar to SushiSwap’s MasterChef contract.

alcueca (judge) commented:

The sponsor acknowledges the issue.

SamSteinGG (Vader) commented:

@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.

The original report as published on Code4rena, by jonah1005. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by jonah1005

View all

39 more disclosed reports, best first.

More from Vader Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.