Function Fees.sellProfits(address) used to swap loan tokens for collateral tokens from liquidations. All token whose address is _profits is swapped to WETH through UniswapV3 Swap router. However, there are 2 parameters ExactInputSingleParams.amountOutMinimum and ExactInputSingleParams.sqrtPriceLimitX96 are set to 0. So the swap will be executed without stop price and without minimum amount out, which implies that it is vulnerable to sandwich attacks
With ExactInputSingleParams.amountOutMinimum = 0 and ExactInputSingleParams.sqrtPriceLimitX96 = 0, the swap is vulnerable to mev bot's sandwich attack that happens within one block. The attack vector is something like this:
Attacker monitored sellProfits transaction
Attacker makes first transaction with a swap that trades a large amount from loan token to WETH (same pair and swap direction with sellProfits) => loan token price dumps
Transaction sellProfits executes with bad price
Attacker makes second transaction with a swap that trades from WETH to loan token and get profits
Amount out from swap is manipulated, which means losing of funds
Foundry
There are 2 options:
Use ISwapRouter.ExactInputSingleParams memory params that is passed from function argument. i.e. update sellProfits(address) to sellProfits(address,ISwapRouter.ExactInputSingleParams)
Use Quoter contract from Uniswap (or use Uniswap library) to get amount out then add a small slippage percents (i.e 0.5%) to that amount. Set the amount to ExactInputSingleParams.amountOutMinimum. This minimum amount out will protect the trade from slippage
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.