Missing Update to omnichain.totalAvailableLiquidationAmount in withdrawUser
Summary
In the deposit function we update omnichain.totalAvailableLiquidationAmount based on the enw deposit, however The Withdraw function processes user withdrawals but fails to update the omnichain.totalAvailableLiquidationAmount. This omission creates a discrepancy between the protocol's actual liquidation capacity and the recorded available amount. While the deposit function correctly adjusts this value, the absence of an update during withdrawals leads to an inflated totalAvailableLiquidationAmount, potentially allowing the protocol to overcommit its liquidation resources.
Root Cause
- The
withdrawUserfunction processes user withdrawals without adjusting theomnichain.totalAvailableLiquidationAmountto reflect the reduced CDS pool. - The
depositfunction, in contrast, correctly updates this value when users contribute to the CDS pool.
Attack Path
- A user withdraws their CDS funds, but the protocol does not update omnichain.totalAvailableLiquidationAmount.
- During liquidation, the protocol calculates user shares based on the inflated value.
- The overestimated
totalAvailableLiquidationAmountcauses some liquidation gains to remain undistributed, locking funds in the protocol.
Impact
- A portion of liquidation gains remains locked in the CDS pool, reducing the funds distributed to eligible users.
- Remaining CDS participants receive a smaller share of the liquidation gains than they are entitled to.
PoC
- State Before Withdrawal:
- omnichain.totalAvailableLiquidationAmount = 1,000,000 USDa.
- User withdraws 200,000 USDa.
- Expected Behavior:
- omnichain.totalAvailableLiquidationAmount is reduced to 800,000 USDa.
- Actual Behavior:
- omnichain.totalAvailableLiquidationAmount remains 1,000,000 USDa.
- During Liquidation:
- Assume liquidation generates 500,000 USDa in gains.
- Share calculation uses the inflated 1,000,000 USDa instead of the actual 800,000 USDa.
- 100,000 USDa of the gains remains locked due to the overestimated pool size.
Mitigation
params.omniChainData.totalAvailableLiquidationAmount -= params.cdsDepositDetails.withdrawedAmount;I should note there seems to be no update on omnichain, this should be looked at