Users are allowed to borrow reserve token using their RAAC NFTs as collateral. For safety reasons, the total borrow amount should be lower than the liquidation threshold, i. e., 80% of the user collateral value (using the base percentage). However, logic to enforce this condition is incorrect in the LendingPool::borrow function, allowing users to borrow up to 125% their collateral amount, resulting in a considerable loss of value for the protocol.
Upper bound of borrow amount is calculated depending on the user collateral value. The condition to authorize a requested amount should be:
collateralValue > userTotalDebt
using the liquidation threshold percentage :
collateralValue * liquidationThreshold > userTotalDebt
or
revert if collateralValue * liquidationThreshold < userTotalDebt.
Currently, the logic to check the borrow amount in the LendingPool::borrow function is incorrect:
revert if collateralValue < userTotalDebt * liquidationThreshold
This condition allows any user to borrow up to 1/liquidationThreshold of their total NFT collateral value (125% when liquidationThreshold is 80%), resulting in significant losses for the protocol.
Assuming that the reserve token is crvUsd and the malicious user interacts with the protocol for the first time, let's take the following example:
Malicious user deposit an NFT valued at 1000 crvUsd
He decides to borrow 1200 crvUsd (higher amount than his collateral value) by calling the LendingPool::borrow function
collateralValue = 1000
userTotalDebt = user.scaledDebtBalance.rayMul(reserve.usageIndex) + amount = 0 + 1200
liquidationThreshold = BASE_LIQUIDATION_THRESHOLD = 80% in basis points
(collateralValue < userTotalDebt.percentMul(liquidationThreshold)) -- > (1000 < (1200 * 0.8))
(1000 < 960) is false, then the process will continue
In this way, a malicious user managed to borrow 20% more crvUsd than the value of their collateral NFT, causing the protocol to lose its funds.
Impact: High
Likelihood: High
Manual Review
Perform a correct validation of the requested amount to borrow:
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.