In the protocol, the addLiquidity function includes a guard to prevent price manipulation.
However, the removeLiquidity function lacks this protection. It only restricts the amount of tokenWithdrawCoin without considering the remaining liquidity in the pool.
An attacker can exploit this by adding liquidity and then removing most of it, leaving a small amount of liquidity in the pool, and donating tokens to the pool to manipulate the price of the token pair.
Impact
Price manipulation
Recommended Mitigation
The remaining liquidity in the pool should be checked when removing liquidity.
Lines of code
https://github.com/code-423n4/2024-05-canto/blob/d1d51b2293d4689f467b8b1c82bba84f8f7ea008/canto-main/x/coinswap/keeper/keeper.go#L253-L320
Vulnerability details
Description
In the protocol, the
addLiquidity
function includes a guard to prevent price manipulation.However, the
removeLiquidity
function lacks this protection. It only restricts the amount oftokenWithdrawCoin
without considering the remaining liquidity in the pool.An attacker can exploit this by adding liquidity and then removing most of it, leaving a small amount of liquidity in the pool, and donating tokens to the pool to manipulate the price of the token pair.
Impact
Price manipulation
Recommended Mitigation
The remaining liquidity in the pool should be checked when removing liquidity.
Assessed type
Other