Closed c4-bot-2 closed 8 months ago
Related to #344
Picodes marked the issue as primary issue
othernet-global (sponsor) acknowledged
othernet-global marked the issue as disagree with severity
othernet-global (sponsor) disputed
This is not an accurate simulation of the liquidation mechanism. In the simulation no WBTC/WETH collateral is deposited (which is required for borrowing USDS). By bypassing the required WBTC/WETH collateral, the automatic arbitrage which is normally present becomes disabled.
As mentioned in the comments above PoolUtils.sol, simulation shows that the arbitrage provides protection against sandwich attacks:
// Simulations (see Sandwich.t.sol) show that when sandwich attacks are used, the arbitrage earned by the protocol sometimes exceeds any amount lost due to the sandwich attack itself.
// The largest swap loss seen in the simulations was 1.8% (under an unlikely scenario). More typical losses would be 0-1%.
// The actual swap loss (taking arbitrage profits generated by the sandwich swaps into account) is dependent on the multiple pool reserves involved in the arbitrage (which are encouraged by rewards distribution to create more reasonable arbitrage opportunities).
Picodes marked the issue as duplicate of #344
Picodes changed the severity to 2 (Med Risk)
Picodes marked the issue as satisfactory
Picodes marked the issue as duplicate of #224
Lines of code
https://github.com/code-423n4/2024-01-salty/blob/main/src/stable/Liquidizer.sol#L139-L141 https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/pools/PoolUtils.sol#L67 https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/dao/DAO.sol#L372
Vulnerability details
Impact
It is possible to capture a significant portion of the POL used for liquidation.
Details
When liquidation occurs, upkeep's logic is as follows
Since anyone can call upkeep multiple times, the above logic is repeated, eventually withdrawing part of the POL, swapping it to usds, and burning the amount of debt.
At this point, a malicious user can steal POL at the following points
First, if liquidizer swap WBTC, WETH, and DAI to USDS, you can capture some of the sandwich because MinAmoutOut is 0.
In the same way, the minAmountOut of the withdrawLiquidityAndClaim called by withdrawPOL is also set to 0, allowing for a certain amount of stealing.
The upkeep makes the attack easier in that it can be performed by an attacker. A malicious contract can be created to hijack the POL in the event of a mass liquidation.
This, combined with a vulnerability that allows liquidation to cause a DoS, could result in an attacker intentionally creating a mass liquidation to steal the POL.
Proof of Concept
After running the above poc code, it took about 100K POL shares to clear the 100K USDS debt. This is equivalent to 100K dai and 100K usds.
In other words, about 50K DAI was stolen by the attack, and more than twice the value was spent to settle the debt.
Recommended Mitigation Steps
There are several ways to solve this problem
Assessed type
Other