Core Contracts

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

Incorrect Collateralization Check in withdrawNFT and borrow Functions

Summary

The withdrawNFT and borrow functions in the contract incorrectly apply the liquidation threshold to the debt instead of the collateral. This allows users to borrow more than their collateral should permit, leading to potential bad debt for the protocol. The correct logic should ensure that the collateral value is at least 125% of the debt (for an 80% liquidation threshold), but the current implementation allows users to borrow up to 100% of their collateral value, which is unsafe.

Vulnerability Details

The withdrawNFT and borrow functions checks:

uint256 public constant BASE_LIQUIDATION_THRESHOLD = 80 * 1e2; // 80% in basis points
liquidationThreshold = BASE_LIQUIDATION_THRESHOLD;
function withdrawNFT(uint256 tokenId) external nonReentrant whenNotPaused {
if (collateralValue - nftValue < userDebt.percentMul(liquidationThreshold)) {
revert WithdrawalWouldLeaveUserUnderCollateralized();
}
  • This checks if the remaining collateral (collateralValue - nftValue) is less than 80% of the debt (userDebt.percentMul(liquidationThreshold)).

  • This is backward because it allows the collateral to be less than the debt, which is unsafe.

Impact

Users can borrow more than their collateral should permit, increasing the risk of bad debt.

Tools Used

Manual

Recommendations

Apply liquidationThreshold on colleteral

if ((collateralValue - nftValue).percentMul(liquidationThreshold)) < userDebt) {
revert WithdrawalWouldLeaveUserUnderCollateralized();
}
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.