sherlock-audit / 2023-05-USSD-judging

9 stars 7 forks source link

evilakela - No slippage protection in USSD#UniV3SwapInput #924

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

evilakela

high

No slippage protection in USSD#UniV3SwapInput

Summary

The USSD#UniV3SwapInput executes swaps without slippage protection. That will cause a loss of funds because of sandwich attacks.

Vulnerability Detail

Impact

Swaps will be sandwiched causing a loss of funds for protocol. Rebalance won't work: suppose USSD price go down and rebalancer need to sell some collateral but due to sandwitch attack amountOut will be very small, and rebalance can be called again and again draining all collateral

Code Snippet

https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/USSD.sol#L227-L240

Tool used

Manual Review

Recommendation

Calculate and set properly amountOutMinimum swap parameter

Duplicate of #673