Adding asymmetric liquidity in _addLiquidity results in fewer LP tokens minted than what should be wanted
The contract adds liquidity to a Curve pool using the full balances of three stablecoins without checking their ratio, so an unbalanced deposit mints fewer LP tokens than expected. An attacker can deposit a large amount of one stablecoin to skew the pool and then arbitrage the Curve pool for profit.
yAxis contest
Originally disclosed on Code4rena
Impact
Because the call in _addLiquidity forwards the entire balances of the 3 stablecoins without checking the ratio. between the 3, less liquidity is minted than what should be wanted. Furthermore, an attacker can abuse this arbitrage the forwarded balances if the discrepancy is large enough.
For example, suppose the contract holds $10K each of usdc, usdt, dai. An attacker deposits $100K worth of DAI and get credited with $100K worth of shares in the protocol. Liquidity is added, but since the ratio is now skewed 11:1:1, a lot less liquidity is minted by the stableswap algorithm to the protocol. The attacker can now arbitrage the curve pool for an additional profit.
There doesn’t even need to be an attacker, just an unbalanced amount of user deposits will also lead to lower liquidity minted.
Proof of Concept
Recommended Mitigation Steps
Adding liquidity should probably be managed more manually, it should be added in equal proportion to the curve pool balances, not the contract balances.
Seems the same as #2
GalloDaSballo (judge) commented:
Agree on the finding This finding claims that adding liquidity on Curve while treating each token to have the same weight is a surefire way to get less tokens than expected
While #2 addresses a similar (IMO higher risk) vulnerability
This finding shows how the vault can have a loss of value through how it deals with token accounting
To me this is a unique finding, however am downgrading it to medium
BobbyYaxis (yAxis) noted:
We have mitigated by deploying vaults that only accept the Curve LP token itself used in the strategy. There is no longer an array of tokens accepted. E.g Instead of a wBTC vault, we have a renCrv vault. Or instead of 3CRV vault, we have a mimCrv vault. The strategy want token = the vault token.
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 contract adds liquidity using the contract's entire token balances rather than amounts proportional to the Curve pool's current balances.
Impact
The protocol mints fewer LP tokens than expected, causing a loss of value, and an attacker could arbitrage the skewed Curve pool for additional profit.
What the attacker needed
Contract holds balances of the three stablecoins; attacker can deposit a large amount of one stablecoin
The fix
The project mitigated by deploying vaults that only accept the specific Curve LP token used in the strategy, removing the array of accepted tokens.
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 pool works best when the tokens you add are in the same proportion as the pool already holds. This contract added whatever amounts it had of three stablecoins, even if one was much larger, which made the pool give back fewer pool tokens (LP tokens) than it should. An attacker could exploit that by depositing a lot of one coin, skewing the pool, and then trading against the skewed pool for profit.
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.