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.
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:
- The borrower executes
open position, LOAN_TERM = 7 days - LP executes
reclaimLiquidity()to retrieveLiquidity - On the 6th day, borrower execute
closePosition()->openPosition() - The new
lien.startTime = block.timestamp - LP needs to wait another
7 days - 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 ifreclaimis called. And the suggested change is also valid. Thanks!
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
- The borrower opens a position with a loan term of seven days.
- The LP calls reclaimLiquidity to retrieve their liquidity.
- On the sixth day, the borrower closes the position and immediately opens a new one.
- The new lien start time is set to the current block timestamp.
- 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.