Skip to content
Business logic Audit finding Intermediate

malicious borrowers can follow reclaimLiquidity() then execute addPremium() to invalidate renewalCutoffTime

A borrower could call addPremium() immediately after the LP calls reclaimLiquidity(), setting the lien's start time equal to the renewal cutoff time. This equality bypasses the check in liquidatePosition(), preventing the LP from forcibly closing the position and retrieving liquidity.

bin2chen Follow with ladboy233

Originally disclosed on Code4rena

Submitted by bin2chen, also found by ladboy233

LP can set renewalCutoffTime=block.timestamp by executing reclaimLiquidity(), to force close position

    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();
        }

The restrictions are:

  1. Loan expires
  2. lien.startTime < lps.getRenewalCutoffTime(lien.tokenId)

Since addPremium() will modify lien.startTime = block.timestamp, we need to restrict , if lps.getRenewalCutoffTime(lien.tokenId) > lien.startTime, addPremium() cannot be executed. Otherwise, addPremium() can indefinitely postpone liquidatePosition() to forcibly close position.

    function addPremium(uint96 lienId, uint128 premium0, uint128 premium1) external override nonReentrant {
..
@>     if (lps.getRenewalCutoffTime(lien.tokenId) > lien.startTime) revert Errors.RenewalDisabled();

The problem is that this judgment condition is >, so if lps.getRenewalCutoffTime(lien.tokenId) == lien.startTime, it can be executed.

This leads to, the borrower can monitor the mempool, if LP executes reclaimLiquidity(), front-run or follow closely to execute addPremium(0). It can be executed successfully, resulting in lien.startTime == lps[tokenId].renewalCutoffTime == block.timestamp.

In this case, liquidatePosition() will fail , because the current condition for liquidatePosition() is lien.startTime < lps.getRenewalCutoffTime(lien.tokenId), liquidatePosition() will revert Errors.LiquidationNotMet();.

So by executing reclaimLiquidity() and addPremium() in the same block, it can maliciously continuously prevent LP from retrieving Liquidity.

Impact

Malicious borrowers can follow reclaimLiquidity() then execute addPremium() to invalidate renewalCutoffTime, thereby maliciously preventing the position from being forcibly closed, and LP cannot retrieve Liquidity.

Recommended Mitigation

Use >= lien.startTime to replace > lien.startTime.

In this way, the borrower has at most one chance and cannot postpone indefinitely.

    function addPremium(uint96 lienId, uint128 premium0, uint128 premium1) external override nonReentrant {
..
-       if (lps.getRenewalCutoffTime(lien.tokenId) > lien.startTime) revert Errors.RenewalDisabled();
+       if (lps.getRenewalCutoffTime(lien.tokenId) >= lien.startTime) revert Errors.RenewalDisabled();

wukong-particle (Particle) confirmed and commented:

Good discovery. The suggested change for > into >= is pretty elegant and smart. Thanks!

0xLeastwood (Judge) increased severity to High and commented:

I would consider this pretty severe, not only can you prevent an LP from receiving their liquidity back. The borrower is able to maintain an unhealthy position. Upgrading to high severity.

adriro (Warden) commented:

I don’t think this a high severity issue. The borrower can front-run reclaimLiquidity() (which is also a difficult task to successfully execute every time, and impossible if using private mempools), but the position can still be liquidated if unhealthy, since the liquidation condition also considers an scenario where the margin doesn’t cover fees (closeCache.tokenFromPremium < liquidateCache.tokenFromOwed || closeCache.tokenToPremium < liquidateCache.tokenToOwed).

0xleastwood (Judge) decreased severity to Medium and commented:

Hmm, that is true. There isn’t much risk here of generating bad debt so I will downgrade to medium severity. 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

The check in addPremium() uses a strict greater-than comparison, allowing renewal when the renewal cutoff time equals the lien's start time.

Impact

A malicious borrower could repeatedly prevent the LP from forcibly closing the position and retrieving liquidity, though the position can still be liquidated if unhealthy due to margin checks.

What the attacker needed

Borrower has an active loan; LP calls reclaimLiquidity(); borrower can front-run or follow in same block

The fix

The check in addPremium() should use >= instead of > to prevent renewal when the cutoff time equals the start time.

How it was found

  1. LP calls reclaimLiquidity() to set renewalCutoffTime to the current block timestamp.
  2. Borrower monitors the mempool and front-runs or follows closely with addPremium(0).
  3. addPremium() succeeds because the cutoff time equals the lien's start time.
  4. liquidatePosition() fails because the condition lien.startTime < renewalCutoffTime is not met.

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.

In this lending system, a lender (LP) can set a cutoff time to force-close a loan. The borrower can then renew the loan by paying a premium, which updates the loan's start time. Because the check for renewal only blocks if the cutoff is strictly greater than the start time, the borrower can renew exactly when the cutoff equals the start time, making the loan appear fresh and blocking the forced closure.

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.