Open code423n4 opened 2 years ago
Agree with this finding! Uniswap token swaps are meant to support all types of tokens. It does seem possible for there to be payer
to experience increased slippage because the check operates on getAmountOut()
and not the bought
output.
It's fair to say that this will lead to value leakage, so I think medium
severity is justified.
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2022-01-openleverage/blob/501e8f5c7ebaf1242572712626a77a3d65bdd3ad/openleverage-contracts/contracts/dex/bsc/UniV2ClassDex.sol#L31-L56
While
uniClassBuy()
correctly checks the actually received amount by comparing the before and after the balance of the receiver,uniClassSell()
trusted the result given bygetAmountOut()
. This makesuniClassSell()
can result in an output amount fewer thanminBuyAmount
.https://github.com/code-423n4/2022-01-openleverage/blob/501e8f5c7ebaf1242572712626a77a3d65bdd3ad/openleverage-contracts/contracts/dex/bsc/UniV2ClassDex.sol#L101-L102
Recommendation
Change to: