Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Valid

`borrow()` incorrectly applies `liquidationThreshold` to `totalDebt` instead of `collateralValue`

Summary

Function borrow() in lendingPool implements a require check where it WRONGLY applies liquidation threshold to userDebt instead of collateralValue.

Vulnerability Details

In LendingPool contract, a user can borrow rToken using their NFT collateral. This NFT collateral can be deposited using depositNFT().

The function borrow() implements an important check which validates, whether the user who is trying to borrow rTokens has sufficient collateral(NFT) to cover his total borrowing. SOURCE

function borrow(uint256 amount) external nonReentrant whenNotPaused onlyValidAmount(amount) {
// Ensure the user has enough collateral to cover the new debt
if (collateralValue < userTotalDebt.percentMul(liquidationThreshold)) {
revert NotEnoughCollateralToBorrow();
}

This is achieved by comparing the collateralValue assets of the user against his userTotalDebt(which includes his current borrowing + previous borrowing).

However, there is an issue here. The function incorrectly applies the liquidation threshold to userTotalDebt instead of collateralValue which inadvertently allow user to borrow MORE tokens than his collateral value.

The liquidationThreshold should have been applied on the collateralValue instead, in order to properly validate the borrowing.

If userTotalDebt is greater than collateralValue.percentMul(liquidationThreshold),
then the collateral is insufficient to cover the debt, and the statement should revert.

You want to ensure that the debt is within the borrowing power provided by the collateral.

Impact

Users can borrow MORE rToken than their collateral value.

Tools Used

Manual

Recommendations

Consider replacing the check with this one

if (collateralValue.percentMul(liquidationThreshold) < userTotalDebt)
{
revert NotEnoughCollateralToBorrow();
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

LendingPool::borrow as well as withdrawNFT() reverses collateralization check, comparing collateral < debt*0.8 instead of collateral*0.8 > debt, allowing 125% borrowing vs intended 80%

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.