The current protocol requires swapping tokens in multiple places, such as weth -> ierc20A or ierc20A -> weth.
Primarily, these swaps are executed using the _swap() method.
amountOutMinimum: we are setting to zero, but this is a significant risk in production. For a real deployment, this value should be calculated using our SDK or an onchain price oracle - this helps protect against getting an unusually bad price for a trade due to a front running sandwich or another type of price manipulation
Lines of code
https://github.com/code-423n4/2024-05-bakerfi/blob/59b1f70cbf170871f9604e73e7fe70b70981ab43/contracts/core/hooks/UseSwapper.sol#L72
Vulnerability details
Vulnerability details
The current protocol requires swapping tokens in multiple places, such as
weth -> ierc20A
orierc20A -> weth
. Primarily, these swaps are executed using the_swap()
method.This method does not set
amountOutMinimum
.and when call same miss set
Amount Out
These methods do not have slippage protection.
https://docs.uniswap.org/contracts/v3/guides/swaps/single-swaps
inculde:
UseSwapper._swap()
/_convertFromWETH()
/_convertToWETH()
/_payDebt()
Impact
front running sandwich or another type of price manipulation
Recommended Mitigation
_swap() need set
amountOutMinimum = params.amountOut
call
_swap()
need set params.amountOut Calculating the allowed slippage value accurately.Assessed type
MEV