Skip to content
Business logic Audit finding Intermediate

reclaimLiquidity() Malicious borrowers can force LPs to be unable to retrieve Liquidity by closing and reopening the Position before it expires

A borrower can repeatedly close and reopen a position just before the loan term expires, resetting the start time and preventing the liquidity provider from reclaiming their funds. This lets a malicious borrower lock up the LP's liquidity indefinitely.

bin2chen Follow with adriro and immeas

Originally disclosed on Code4rena

Submitted by bin2chen, also found by adriro and immeas

If LP wants to retrieve the Liquidity that has been lent out, it can set a renewalCutoffTime through reclaimLiquidity(). If the borrower does not voluntarily close, liquidatePosition() can be used to forcibly close the position after the loan expires.

    function liquidatePosition(
        DataStruct.ClosePositionParams calldata params,
        address borrower
    ) external override nonReentrant {
...
        if (
            !((closeCache.tokenFromPremium < liquidateCache.tokenFromOwed ||
                closeCache.tokenToPremium < liquidateCache.tokenToOwed) ||
@>              (lien.startTime < lps.getRenewalCutoffTime(lien.tokenId) &&
@>                 lien.startTime + LOAN_TERM < block.timestamp))
        ) {
            revert Errors.LiquidationNotMet();
        }

To forcibly close the position, we still need to wait for the expiration block.timestamp > lien.startTime + LOAN_TERM.

But currently, openPosition() is not restricted by renewalCutoffTime, as long as there is Liquidity, we can open a position.

In this way, malicious borrowers can continuously occupy Liquidity by closing and reopening before expiration. For example:

  1. The borrower executes open position, LOAN_TERM = 7 days
  2. LP executes reclaimLiquidity() to retrieve Liquidity
  3. On the 6th day, borrower execute closePosition() -> openPosition()
  4. The new lien.startTime = block.timestamp
  5. LP needs to wait another 7 days
  6. The borrower repeats the 3rd step, indefinitely postponing

The borrower may need to pay a certain fee when openPosition(). If the benefits can be expected, it is very cost-effective.

Impact

Malicious borrowers can force LPs to be unable to retrieve Liquidity by closing and reopening the Position before it expires.

Recommended Mitigation

It is recommended that when openPosition(), if the current time is less than renewalCutoffTime + LOAN_TERM + 1 days, do not allow new positions to be opened, giving LP a time window for retrieval.

Or set a new flag TOKEN_CLOSE = true to allow lp to specify that Liquidity will no longer be lent out.

    function openPosition(
        DataStruct.OpenPositionParams calldata params
    ) public override nonReentrant returns (uint96 lienId, uint256 collateralTo) {
...
+     require(block.timestamp > (lps[params.tokenId].renewalCutoffTime + LOAN_TERM + 1 days),"LP Restrict Open ");

wukong-particle (Particle) confirmed and commented:

This is an interesting discovery. Our original thinking was after reclaim, LP can withdraw liquidity in one tx via multicall. But the problem here is that the already borrowed liquidity can be extended indefinitely. We should probably just restrict new positions to be opened if reclaim is called. And the suggested change is also valid. Thanks!


The original report as published on Code4rena, by bin2chen. 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

Likely the openPosition function does not check the LP's renewal cutoff time, so a borrower can always open a new position and reset the loan start time.

Impact

A malicious borrower could indefinitely prevent an LP from retrieving their liquidity, though the borrower may need to pay a fee each time they reopen.

What the attacker needed

Borrower has an active position; LP has called reclaimLiquidity; borrower can pay the opening fee

The fix

The project should restrict opening new positions when the current time is close to the renewal cutoff time plus the loan term, or add a flag to stop lending; the team confirmed the issue and agreed the suggested change is valid.

How it was found

  1. The borrower opens a position with a loan term of seven days.
  2. The LP calls reclaimLiquidity to retrieve their liquidity.
  3. On the sixth day, the borrower closes the position and immediately opens a new one.
  4. The new lien start time is set to the current block timestamp.
  5. The LP must wait another seven days, and the borrower can repeat this indefinitely.

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.

A liquidity provider (LP) lends tokens to a borrower for a fixed loan term. The LP can ask for the money back, but the borrower can keep resetting the loan by closing and reopening it just before it expires, so the LP never gets the money back.

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 bin2chen

View all

139 more disclosed reports, best first.

More from Particle Leverage AMM Protocol Invitational

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.