The borrow and withdrawNFT functions use flawed collateralization checks, allowing users to borrow more than their collateral supports or withdraw NFTs, leaving them undercollateralized. This undermines the protocol’s safety mechanisms.
Location:
borrow
: Line if (collateralValue < userTotalDebt.percentMul(liquidationThreshold))
withdrawNFT
: Line if (collateralValue - nftValue < userDebt.percentMul(liquidationThreshold))
Problem:
In borrow
, the check allows borrowing as long as collateralValue >= userTotalDebt * liquidationThreshold / 10000
, but it should ensure userTotalDebt <= collateralValue * liquidationThreshold / 10000
.
In withdrawNFT
, the check fails to ensure the resulting health factor remains ≥ 1e18, allowing undercollateralization.
Attack Scenario:
Setup: User deposits an NFT worth 100 crvUSD, liquidationThreshold = 80_00
(80%), and borrows 80 crvUSD (usageIndex = 1e27
).
Borrow Exploit:
Current debt = 80 crvUSD. User tries to borrow 20 more (total = 100 crvUSD).
Check: 100 < 100 * 0.8 = 80
(false, borrow allowed), but 100 * 0.8 = 80 < 100
, so debt exceeds collateral threshold (should fail).
Result: User borrows 100 crvUSD with 100 crvUSD collateral, immediately liquidatable.
WithdrawNFT Exploit:
Debt = 80 crvUSD, collateral = 100 crvUSD. User withdraws the NFT (value 100).
Check: 100 - 100 = 0 < 80 * 0.8 = 64
(true, reverts), but if collateral drops to 0, health factor should be < 1e18 (should fail earlier).
Result: Incorrect logic allows unsafe withdrawals if misinterpreted.
The vulnerable code snippets :
Undercollateralized Loans: Users can borrow beyond their collateral’s safe limit, risking instant liquidation or insolvency.
Protocol Losses: Liquidations may fail to recover enough value if collateral is insufficient, leading to losses.
Systemic Risk: Widespread undercollateralization undermines trust and stability.
Manual Review
Correct the collateralization check in borrow:
Use health factor check in withdrawNFT
:
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.