Skip to content
Business logic Audit finding Advanced

Malicious user can DOS pool and avoid liquidation by creating secondary liquidity pool for Velodrome token pair

The vault's pricing function uses the Velodrome router to get the best price across stable and volatile pools, but requires the trade to go through the correct pool type. A malicious user can manipulate the price of the opposite pool so that the router routes through the wrong pool, causing liquidation calls to revert and avoiding liquidation.

0x52 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-isomorph-judging/issues/72

Found by

0x52

Summary

For every Vault_Velo interaction the vault attempts to price the liquidity of the user. This calls priceLiquidity in the corresponding DepsoitReciept. The prices the underlying assets by swapping them through the Velodrome router. Velodrome can have both a stable and volatile pool for each asset pair. When calling the router directly it routes through the pool that gives the best price. In priceLiquidity the transaction will revert if the router routes through the wrong pool (i.e. trading the volatile pool instead of the stable pool). A malicious user can use this to their advantage to avoid being liquidated. They could manipulate the price of the opposite pool so that any call to liquidate them would route through the wrong pool and revert.

Vulnerability Detail

    uint256 amountOut; //amount received by trade
    bool stablePool; //if the traded pool is stable or volatile.
    (amountOut, stablePool) = router.getAmountOut(HUNDRED_TOKENS, token1, USDC);
    require(stablePool == stable, "pricing occuring through wrong pool" );

DepositReceipt uses the getAmountOut call the estimate the amountOut. The router will return the best rate between the volatile and stable pool. If the wrong pool give the better rate then the transaction will revert. Since pricing is called during liquidation, a malicious user could manipulate the price of the wrong pool so that it returns the better rate and always reverts the liquidation call.

Impact

Malicious user can avoid liquidation

Code Snippet

https://github.com/sherlock-audit/2022-11-isomorph/blob/main/contracts/Velo-Deposit-Tokens/contracts/DepositReceipt_USDC.sol#L75-L130

Tool used

Manual Review

Recommendation

Instead of quoting from the router, query the correct pool directly:

        uint256 amountOut; //amount received by trade
-       bool stablePool; //if the traded pool is stable or volatile.

-       (amountOut, stablePool) = router.getAmountOut(HUNDRED_TOKENS, token1, USDC);
-       require(stablePool == stable, "pricing occuring through wrong pool" );
+       address pair;

+       pair = router.pairFor(token1, USDC, stable)
+       amountOut = IPair(pair).getAmountOut(HUNDRED_TOKENS, token1)

Discussion

kree-dotcom

Fixed https://github.com/kree-dotcom/Velo-Deposit-Tokens/commit/58b8f3e14b416630971b7b17b500bbe22d2016aa

Note there are two fixes in this commit relating to the priceLiquidity function. The other fix is for issue #145 , the code for these changes doesn't overlap so should be clear.

0x00052

Fixes look good. The pair is now requested directly from the router

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

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

The pricing function relies on the router's best-price selection and then requires a specific pool type, which can be manipulated by changing the relative prices of the two pools.

Impact

A malicious user could avoid liquidation, potentially leaving the protocol with bad debt.

What the attacker needed

Ability to create or manipulate a liquidity pool; victim has a position eligible for liquidation

The fix

The pricing function was fixed to query the correct pool directly instead of using the router's best-price selection.

How it was found

  1. Create or manipulate a secondary liquidity pool for the token pair.
  2. Manipulate the price of the opposite pool so it gives a better rate.
  3. When liquidation is attempted, the router routes through the wrong pool and the transaction reverts.

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 someone borrows money against their collateral, the system checks the collateral's value to decide if they can be liquidated. Here, that check uses a price router that picks the best price from two pools. An attacker can make the wrong pool look better, so the check fails and liquidation is blocked.

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 0x52

View all

211 more disclosed reports, best first.

More from Isomorph

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.