Core Contracts

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

User can be unliquidatable

Summary

The finalizeLiquidation function in the LendingPool contract contains an unbounded loop that processes all of a user's deposited NFTs in a single transaction. If a user has deposited a large number of NFTs, the gas required to process this loop could exceed the block gas limit, causing the function to fail with an "out of gas" error.

Details

Normally, since NFTs are houses, one user holding hundreds of house NFTs doesn’t seem that feasible. But I look at the real world, and think of a scenario where an organization is just buying more and more houses for a business, either renting them, or for some other reasons. Or, a collective multisig buying a whole bunch of house NFTs for a collective living arrangement. In that case, there’s a chance that that very user, in the scenario where they are liquidatable, they cannot be liquidated due to OOG on LendingPool::finalizeLiquidation

Look at this block in finalizeLiquidation function:

// Transfer NFTs to Stability Pool //@audit possible OOG
for (uint256 i = 0; i < user.nftTokenIds.length; i++) {
uint256 tokenId = user.nftTokenIds[i];
user.depositedNFTs[tokenId] = false;
raacNFT.transferFrom(address(this), stabilityPool, tokenId);
}
delete user.nftTokenIds;

Imagine that the collective multisig that’s holding all those NFT houses should be liquidated for this or that reason. Since this function is the only way to do so, in the case of large NFT sums, this function will always revert due to OOG. The user could never be liquidated, putting the protocol into bad debt and causing insolvency.

Just as an example, think of how expensive transferFrom function will get, each and every time.

Impact

If a user deposits a sufficiently large number of NFTs as collateral, their position could become "unliquidatable" due to the gas limitations. This breaks a core mechanism of the protocol and could lead to bad debt that cannot be recovered, threatening the protocol's solvency.

Recommendation

I think the best way to approach this issue could be to handle NFTs in batches, or instead of immediately transferring the NFT in the loop, you can use a pull method where you write it somewhere else, and add a function that would transfer the required NFTs separately.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

LendingPool: Unbounded NFT array iteration in collateral valuation functions creates DoS risk, potentially blocking liquidations and critical operations

LightChaser L-36 and M-02 covers it.

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

LendingPool: Unbounded NFT array iteration in collateral valuation functions creates DoS risk, potentially blocking liquidations and critical operations

LightChaser L-36 and M-02 covers it.

Support

FAQs

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