Due to incorrect logic, users are able to withdraw NFTs even if their collateral value falls below the allowed level. This results in users not having enough collateral with respect to their active debt, which is not an intended system behavior and results in significant losses for the protocol.
Users should be allowed to withdraw their RAAC NFTs if and only if the remaining collateral value is enough to maintain the liquidation threshold. Upper limit of the withdrawal value is calculated based on the user remaining collateral value. The condition to authorizing the withdrawal of an NFT must be:
RemainingCollateralValue > userTotalDebt
using the liquidation threshold percentage:
RemainingCollateralValue * liquidationThreshold > userTotalDebt
or
revert if (RemainingCollateralValue * liquidationThreshold < userTotalDebt).
Currently, the logic to validate the withdrawal value in the LendingPool::withdrawNFT function is incorrect:
revert if (RemainingCollateralValue < userDebt * liquidationThreshold)
This condition allows any user to withdraw NFTs with a higher value than expected, leaving them undercollateralized and affecting the functionality and liquidity of the protocol.
Assuming that the reserve token is crvUsd and liquidationThreshold = BASE_LIQUIDATION_THRESHOLD = 80%, let's take the following example:
UserA has 3 RAAC NFTs deposited in the pool, which are
NFT1 (25,000 crvUsd)
NFT2 (14,000 crvUsd)
NFT3 (31,000 crvUsd)
UserA current debt is 55,000 crvUsd (78% of his collateral value)
He decides to withdraw his NFT1 by calling the LendingPool::withdrawNFT function (would leave him undercollateralized)
userDebt = 55000
collateralValue = getUserCollateralValue(msg.sender) = 70000
nftValue = getNFTPrice(NFT1) = 25000
(collateralValue - nftValue < userDebt.percentMul(liquidationThreshold))
70000 - 25000 < 55000 * 0.8
(45000 < 44000) is false, then the process will continue
After the operation, collateral value of userA is NFT2 + NFT3 = 45,000 crvUsd, while his current debt is 55,000 crvUsd
In this way, malicious user managed to withdraw his NFT and become undercollateralized, causing losses to the protocol.
Impact: High
Likelihood: High
Manual Review
Perform a correct validation of the remaining collateral value:
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.