Core Contracts

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

Incorrect Collateral Threshold Check in Borrow Logic

Summary

The borrow function allows a user to borrow an amount of reserve assets. It checks that the user has enough collateral to cover the new debt. However, the collateral check incorrectly applies the liquidation threshold to the user debt instead of the collateral value. This incorrect implementation allows users to borrow an amount higher than the collateral provided, potentially leading to undercollateralized positions, bad debts, and protocol insolvency

Vulnerability Details

Here's the collateral check from borrow

function borrow(uint256 amount) external nonReentrant whenNotPaused onlyValidAmount(amount) {
.....
uint256 collateralValue = getUserCollateralValue(msg.sender);
......
// Fetch user's total debt after borrowing
uint256 userTotalDebt = user.scaledDebtBalance.rayMul(reserve.usageIndex) + amount;
// Ensure the user has enough collateral to cover the new debt
if (collateralValue < userTotalDebt.percentMul(liquidationThreshold)) {
revert NotEnoughCollateralToBorrow();
}
....
}

The check is incorrect because It applies liquidationThreshold to userTotalDebt instead of collateralValue.

Example scenario:

Values:

  • collateralValue = 100 ETH

  • borrow amount = 120 ETH

  • userTotalDebt = 120 ETH(assuming there's no previous debt)

  • liquidationThreshold = 80%

Current calculation (incorrect): 100 ETH < 96 ETH (120 * 80%) Check passes since 100 > 96, allowing borrowing

Correct calculation: (100) * 80% = 80 ETH < 120 ETH Check should fail as 80 < 120, preventing borrowing

Impact

  • Users can borrow more than their deposited collateral

  • Risk of bad debts and protocol insolvency

Tools Used

Manual

Recommendations

Fix the collateral check

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

Lead Judging Commences

inallhonesty Lead Judge 3 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.