The liquidation finalization process in the LendingPool contract has a flaw in the state management between debt clearing and NFT collateral transfers. When finalizing liquidations, the contract allows NFT transfers before properly clearing associated debt, creating potential value extraction opportunities.
The issue is the non-atomic sequence of operations: liquidation flags are cleared and NFTs are transferred before the debt is actually settled and assets are transferred. This creates multiple points where the system state could become inconsistent if any of the later operations fail.
The order of operations in finalizeLiquidation allows a state where NFTs are transferred before debt is fully cleared. "Imagine a house being foreclosed, but the bank transfers the deed before clearing the mortgage. That's exactly what's happening in the RAAC protocol's liquidation process. When the StabilityPool finalizes a liquidation, the valuable NFT collateral moves before the borrower's debt record is cleared."
The story unfolds in three acts:
First, a borrower defaults on their loan, triggering the liquidation grace period of 3 days (defined as BASE_LIQUIDATION_GRACE_PERIOD
). During this time, their NFT-backed real estate collateral sits in limbo within the LendingPool.
Next, once the grace period expires, anyone can call finalizeLiquidation()
. Here's where things get interesting, the function transfers the NFT collateral to the StabilityPool immediately, but the crucial debt clearing operation happens in a separate, non-atomic step.
Finally, this sequence creates a dangerous window where the protocol's accounting becomes misaligned. The StabilityPool holds the NFT collateral while the LendingPool still shows outstanding debt for the borrower. In concrete terms, a $500,000 house-backed NFT could be transferred while its associated debt remains recorded, effectively double-counting the collateral value in the system.
The liquidation process transfers NFTs to the StabilityPool but may not properly clear user debt, creating a mismatch between collateral and debt state.
The fix requires treating the NFT transfer and debt clearing as a single atomic operation, much like how a real estate closing handles both deed transfer and mortgage settlement simultaneously. Here's how:
This approach ensures the protocol maintains perfect alignment between collateral ownership and debt records, just as traditional finance demands for secured lending.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.