The withdrawNFT function in LendingPool implements a flawed collateralization check that incorrectly applies the liquidation threshold to the user's debt instead of calculating the required collateral value. This allows users to withdraw NFTs even when their remaining collateral would be insufficient to secure their outstanding debt.
In the withdrawNFT function:
The vulnerability exists because:
The check applies liquidationThreshold to debt (userDebt.percentMul(liquidationThreshold))
Should instead calculate minimum required collateral (userDebt.percentDiv(liquidationThreshold))
Initial state:
userTotalDebt: 2000
collateralValue: 2500
nftValue: 700
liquidationThreshold: 75%
Current flawed check:
collateralValue - nftValue < (userDebt * liquidationThreshold)
2500 - 700 < (2000 * 75%)
1800 < 1500 (allows withdrawal)
Since 1800 is not less than 1500, the function allows withdrawal.
After withdrawal, remaining collateral would be insufficient:
collateralValue: 1800
userTotalDebt: 2000
This means the user’s remaining collateral is not enough to properly secure their debt.
Correct check should be:
Required collateral = userDebt / liquidationThreshold
Required collateral = 2000 / 0.75 = 2667
1800 < 2667 (should revert)
Users can withdraw NFTs leaving positions undercollateralized
Protocol's core safety mechanism is compromised
Potential for significant bad debt accumulation
Risk of protocol insolvency through systematic exploitation
Manual code review
Implement correct collateralization check:
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.