Users can lose money if they repay their loan after the liquidation grace period has passed. This occurs because the repayment does not close the liquidation process, and the Stability Pool is the only entity that can finalize the liquidation after GRACE_PERIOD
by calling the LendingPool::finalizeLiquidation
function on the LendingPool contract. Additionally, if a user repays after the grace period, the Stability Pool's StabilityPool::liquidateBorrower
function will fail, leaving the NFT collateral stuck and unrecoverable by either the user or the Stability Pool it is worthy to note that calling the finalizeLiquidation
instead of the liquidateBorrower
doesn't have this issue of the user being unable to be liquidated. This issue also affects third parties who attempt to repay the debt on behalf of the user after the grace period, resulting in a loss of funds for them as well.
This can also occur as user may pay for their debt and not call closeLiquidation
before the GRACE_PERIOD
ends and they also lose their paid money and collaterized NFT.
Affected Code:
The vulnerability arises due to the lack of a check in the repay
function to prevent users from repaying their debt after the liquidation grace period has expired. This allows users to repay their debt even when the liquidation process cannot be finalized, leading to a loss of funds and locked collateral.
Paste the following code into the LendingPool.test.js
file.
Users can lose funds if they repay their loan after the liquidation grace period has passed.
The NFT collateral can become stuck and cannot be withdrawn by either the user or the Stability Pool.
Third parties who attempt to repay the debt on behalf of the user after the grace period also lose their funds.
Hardhat
Manual Review
Add a Check in the repay
Function: Implement a check in the repay
function to prevent users from repaying their debt after the liquidation grace period has expired. This can be done by verifying the liquidation status and the elapsed time since the liquidation started.
Add a check in liquidateBorrower()
and finalizeLiquidation()
to reset liquidation status when userDebt == 0 && user.isUnderLiquidation
. For example:
This prevents users from remaining in liquidation status after their debt is cleared by the user or another user and they failed to call closeLiquidation
before the period expired.
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.