Core Contracts

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

Insufficient Collateral Validation in Borrow Function Allows Excess Debt

Summary

The borrow function checks collateralization after updating state instead of validating the requested amount upfront.

Vulnerability Details

function borrow(uint256 amount) external {
// State updates happen before validation
userTotalDebt += amount;
// Too late - debt already increased
if (collateralValue < userTotalDebt.percentMul(liquidationThreshold)) {
revert NotEnoughCollateralToBorrow();
}
}

The LendingPool contract allows users to borrow amounts that exceed their safe collateralization ratio. When a user with 1,000,000 worth of collateral attempts to borrow 900,000 tokens, the transaction will succeeds despite the liquidation threshold of 80% limiting the maximum borrow to 800,000 tokens.

Let's say a user deposits collateral worth 1,000,000 tokens. They then call borrow(900000). The contract updates the debt before validating against the liquidation threshold, allowing the position to become undercollateralized. This creates an immediate liquidation opportunity and puts protocol funds at risk.

// Current state
collateralValue = 1000000
liquidationThreshold = 8000 (80%)
maxBorrow = collateralValue * liquidationThreshold = 800000
// Attacker transaction
borrow(amount=900000) // Succeeds when it should fail

This allows users to take on more debt than their collateral supports, creating undercollateralized positions. This puts the protocol's solvency at risk and could trigger a cascade of liquidations if asset prices decline.

Impact

The LendingPool allows borrowing amounts that exceed the safe collateralization ratio, putting the protocol at risk of undercollateralized positions.

Recommendations

Add pre-validation of borrow amount

uint256 maxBorrow = collateralValue.percentMul(liquidationThreshold);
if (amount > maxBorrow) revert BorrowExceedsCollateral();
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 month 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.