Core Contracts

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

corrupt liquidationthreshold calculation in withdraw nft

Vulnerability Details

The withdrawNFT function uses the same flawed logic as the borrow function, applying the liquidation threshold to debt instead of collateral. This allows users to withdraw NFTs even if the remaining collateral becomes insufficient to cover their debt, leading to undercollateralized positions.

https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/pools/LendingPool/LendingPool.sol#L302-L303

if (collateralValue - nftValue < userDebt.percentMul(liquidationThreshold)) {
revert WithdrawalWouldLeaveUserUnderCollateralized();

Proof of Concept

uint256 collateralValue = 200$

uint256 nftValue = 100$

uint256 userDebt = 125$

uint256 liquidationThreshold = 8000; // 80% in basis points

What the code does

userDebt.percentMul(liquidationThreshold) = 125e18 * 8000 / 10000 = 100e18 ($100)

if (100e18 < 100e18) → false → withdrawal allowed

Impact

The inverted check allows collateral to drop below debt / threshold leavinf the debt undercollaterlized leading to loss of funds for the protocol

Tools Used

Recommendations

use the correct logic for liquidationthreshold calculation

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.