Submitted by bin2chen, also found by adriro, ladboy233 (1, 2), and immeas
When the Loan expires, and RenewalCutoffTime has been set, anyone can execute the liquidation method liquidatePosition().
Execution path: liquidatePosition() -> _closePosition() -> Base.swap(params.data)
The problem is that this params.data can be arbitrarily constructed by the liquidator.
As long as there is enough amountReceived after the exchange for repayment, it will not revert.
In this way, you can maliciously construct data and steal the extra profit of the liquidator. (At least amountReceived must be guaranteed)
Assume:
collateral + tokenPremium = 120
repay minimum amountReceived only need 100 to swap
so borrower Profit 120 - 100 = 20
Add to LiquidationTest.t.sol:
Liquidator can construct malicious data to steal the borrowers profit.
It is recommended to remove data.
The protocol already knows the token0/token1 and params.amountSwap that need to be exchanged, which is enough to construct the elements needed for swap.
wukong-particle (Particle) commented:
0xleastwood (Judge) commented:
wukong-particle (Particle) acknowledged, but disagreed with severity and commented:
0xleastwood (Judge) commented:
wukong-particle (Particle) commented:
bin2chen (Warden) commented:
wukong-particle (Particle) confirmed and commented:
0xleastwood (Judge) commented:
