Platform: Code4rena
Start Date: 12/08/2022
Pot Size: $50,000 USDC
Total HM: 15
Participants: 120
Period: 5 days
Judge: Justin Goro
Total Solo HM: 6
Id: 153
League: ETH
Rank: 8/120
Findings: 1
Award: $2,282.09
🌟 Selected for report: 1
🚀 Solo Findings: 0
2282.0928 USDC - $2,282.09
Leftover shares in liquidateClean
are only subtracted from pair totals, but not from user's borrowed shares. This means that after liquidateClean
, borrower's shares will be greater than 0
(leftover shares after liquidations), but the user is still insolvent and can be liquidated again and again (with _sharesToLiquidate
set to 0
). Each subsequent liquidation will write off the bad debt (reduce pair totals by borrower leftover shares/amounts), but doesn't take anything from liquidator nor borrower (since _sharesToLiquidate == 0
).
This messes up the whole pair accounting, with total asset amounts reducing and total borrow amounts and shares reducing. This will make it impossible for borrowers to repay debt (or be liquidated), because borrow totals will underflow, and lenders amount to withdraw will reduce a lot (they will share non-existant huge bad debt).
Reducing pair totals scenario:
1000 FRAX
(1000
shares) against 1.5 ETH
collateral (1 ETH = 1000
, Max LTV
= 75%
)500
very quickly with liquidators being unable to liquidate Alice due to network congestion500
, Alice collateral is worth 750
against 1000 FRAX
debt, making Alice insolvent and in a bad debtliquidateClean
for 800
shares, which cleans up all available collateral of 1.5 ETH
.200
shares debt with 0
collateralliquidateClean
with 0
shares to liquidate. Each call pair totals are reduced by 200
shares (and total borrow amount by a corresponding amount).0
, the pool is effectively locked. Borrowers can't repay, lenders can withdraw severly reduced amounts.Copy this to src/test/e2e/LiquidationBugTest.sol
https://gist.github.com/panprog/cbdc1658d63c30c9fe94127a4b4b7e72
After the line
add
_sharesToLiquidate += _sharesToAdjust;
#0 - 0xA5DF
2022-08-17T20:57:12Z
Duplicate of #112
#1 - amirnader-ghazvini
2022-08-29T18:52:18Z
Duplicate of #112
#2 - gititGoro
2022-10-02T19:53:04Z
Setting to original in set.