Skip to content
Business logic Audit finding Intermediate

User can pass auction recovery health check easily with flashloan

The auction recovery health check only verifies the account's health factor at the moment of the transaction, so a user can temporarily inflate their collateral with a flash loan to cancel an auction and then withdraw the funds. This allows the user to bypass the recovery requirement and delay liquidation.

Trust Follow

Originally disclosed on Code4rena

Submitted by Trust

https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/protocol/pool/PoolParameters.sol#L281

ParaSpace features an auction mechanism to liquidate user’s NFT holdings and receive fair value. User has the option, before liquidation actually happens but after auction started, to top up their account to above recovery factor (> 1.5 instead of > 1) and use setAuctionValidityTime() to invalidate the auction.

require(
    erc721HealthFactor > ps._auctionRecoveryHealthFactor,
    Errors.ERC721_HEALTH_FACTOR_NOT_ABOVE_THRESHOLD
);
userConfig.auctionValidityTime = block.timestamp;

The issue is that the check validates the account is topped in the moment the TX is executed. Therefore, user may very easily make it appear they have fully recovered by borrowing a large amount of funds, depositing them as collateral, registering auction invalidation, removing the collateral and repaying the flash loan. Reentrancy guards are not effective to prevent this attack because all these actions are done in a sequence, one finishes before the other begins. However, it is clear user cannot immediately finish this attack below liquidation threshold because health factor check will not allow it.

Still, the recovery feature is a very important feature of the protocol and a large part of what makes it unique, which is why I think it is very significant that it can be bypassed. I am on the fence on whether this should be HIGH or MED level impact, would support judge’s verdict either way.

Impact

User can pass auction recovery health check easily with flashloan.

Proof of Concept

  1. User places NFT as collateral in the protocol

  2. User borrows using the NFT as collateral

  3. NFT price drops and health factor is lower than liquidation threshold

  4. Auction to sell NFT initiates

  5. User deposits just enough to be above liquidation threshold

  6. User now flashloans 1000 WETH

    1. supply 1000 WETH to the protocol
    2. call setAuctionValidityTime(), cancelling the auction
    3. withdraw the 1000 WETH from the protocol
    4. pay back the 1000 WETH flashloan
  7. End result is bypassing of recovery health check

Recommended Mitigation Steps

In order to know user has definitely recovered, implement it as a function which holds the user’s assets for X time (at least 5 minutes), then releases it back to the user and cancelling all their auctions.

LSDan (judge) commented:

I agree with high risk for this. It’s a direct attack on the intended functionality of the protocol that can result in a liquidation delay and potential loss of funds.


The original report as published on Code4rena, by Trust. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The health check is performed only at the time of the transaction, without requiring the collateral to remain for any period, allowing a flash loan to temporarily satisfy the condition.

What the attacker needed

User has an NFT collateral with an ongoing auction; Access to a flash loan provider

The fix

The recovery should be implemented as a function that holds the user's assets for a minimum time (e.g., at least 5 minutes) before releasing them and cancelling auctions.

How it was found

  1. User places NFT as collateral and borrows against it.
  2. NFT price drops and health factor falls below liquidation threshold.
  3. Auction to sell the NFT initiates.
  4. User deposits just enough to be above liquidation threshold.
  5. User flashloans 1000 WETH, supplies it to the protocol, calls setAuctionValidityTime() to cancel the auction, withdraws the WETH, and repays the flashloan.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a user's NFT collateral loses value, the protocol starts an auction to sell it. The user can stop the auction by proving they have enough collateral, but the check only looks at the balance for an instant. By borrowing a large sum temporarily (a flash loan), they can appear to have enough, cancel the auction, and then return the borrowed money.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Trust

View all

77 more disclosed reports, best first.

More from ParaSpace contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.