The liquidation threshold (LT) in the withdrawal and borrow check is applied incorrectly to the user's debt instead of their collateral. This could allow users to withdraw collateral in situations where they should not be allowed to, potentially leading to undercollateralization.
The current implementation of the withdrawal condition is:
The current implementation of the debt condition is:
Problem: The liquidationThreshold
should be applied to the collateral, not the debt.
Incorrect Logic: The condition incorrectly compares the remaining collateral to a fraction of the debt, which can allow withdrawals that would leave the user undercollateralized.
Correct Logic: The proper check should ensure that the post-withdrawal collateral is still sufficient to cover the debt based on the liquidation threshold:
Parameter | Value |
---|---|
collateralValue |
10 ETH |
nftValue |
2 ETH |
userDebt |
6 ETH |
liquidationThreshold |
80% (0.8) |
Incorrect Calculation:
This incorrectly allows withdrawal since 8 ETH is greater than 4.8 ETH, but the correct threshold should be checked against 6 ETH.
Correct Calculation:
This correctly prevents undercollateralized withdrawals.
run in LendingPool..test.js
** Under-Collateralization:** Users are able to withdraw more collateral than they should, leading to situations where their remaining collateral is insufficient to cover their outstanding debt.
Economic Losses: If users are undercollateralized, liquidations may not be able to fully recover the protocol’s losses resulting in bad debt
user can steal funds from protocol.
Manual Code Review
Apply LT to Collateral Instead of Debt: Modify the condition as follows:
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.