Skip to content
Business logic Audit finding Intermediate

User deposits don’t have min. return checks

The deposit function in LPIssuer computes balanced amounts based on current vault token TVLs, but a strategist can frontrun by rebalancing the vault, changing the TVLs and causing the user's deposit to be rebalanced differently, resulting in fewer LP tokens minted than expected. An attacker (or the strategist) could exploit this to make users receive an unpredictable and potentially much lower share of the pool.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

The LPIssuer.deposit first computes balanced amounts on the user’s defined tokenAmounts. The idea is that LP tokens give the same percentage share of each vault tokens’ tvl, therefore the provided amounts should be balanced, meaning, the depositAmount / tvl ratio should be equal for all vault tokens.

But the strategist can frontrun the user’s deposit and rebalance the vault tokens, changing the tvl for each vault token which changes the rebalance. This frontrun can happen accidentally whenever the strategist rebalances

Proof Of Concept

There’s a vault with two tokens A and B, tvls are [500, 1500]

  • The user provides [500, 1500], expecting to get 50% of the share supply (is minted 100% of old total supply).
  • The strategist rebalances to [1000, 1000]
  • The user’s balanceFactor is min(500/1000, 1500/1000) = 1/2, their balancedAmounts are thus tvl * balanceFactor = [500, 500], the 1000 excess token B are refunded. In the end, they only received 500/(1000+500) = 33.3% of the total supply but used up all of their token A which they might have wanted to hold on to if they had known they’d only get 33.3% of the supply.

Impact

Users can get rekt when depositing as the received LP amount is unpredictable and lead to a trade using a very different balanced token mix that they never intended.

Recommended Mitigation Steps

Add minimum return amount checks. Accept a function parameter that can be chosen by the user indicating their expected LP amount for their deposit tokenAmounts, then check that the actually minted LP token amount is above this parameter.

MihanixA (Mellow Protocol) confirmed

The original report as published on Code4rena, by cmichel. 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 deposit function lacks a user-specified minimum LP token amount, so the actual minted amount can be lower than expected due to frontrunning rebalances.

Impact

Users can get rekt when depositing as the received LP amount is unpredictable and lead to a trade using a very different balanced token mix that they never intended.

What the attacker needed

User deposits into the vault; Strategist frontruns with a rebalance

How it was found

  1. User provides token amounts [500, 1500] to a vault with TVLs [500, 1500], expecting 50% of share supply.
  2. Strategist rebalances the vault to TVLs [1000, 1000].
  3. User's balanceFactor becomes min(500/1000, 1500/1000) = 1/2, balancedAmounts become [500, 500], and 1000 excess token B are refunded.
  4. User receives only 500/(1000+500) = 33.3% of total supply instead of 50%.

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 deposit into a vault, the system calculates how many pool tokens you get based on the current balance of the vault. If someone else changes the balance just before your deposit, you might get fewer pool tokens than you expected. This report shows that without a minimum return check, users can lose out.

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 cmichel

View all

196 more disclosed reports, best first.

More from Mellow 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.