Skip to content
Business logic Audit finding Intermediate

LendingPair.withdrawUniPosition should accrue debt first

The withdrawUniPosition function in LendingPair does not accrue debt before allowing a user to withdraw their Uniswap V3 position NFT, which serves as collateral. In low-activity markets, this could let an account with a de-facto negative health ratio withdraw collateral without repaying debt.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel.

The LendingPair.withdrawUniPosition function allows the user to withdraw their UniswapV3 pool position (NFT) again. As the Uniswap position acts as collateral in the protocol, a health check is performed afterwards.

However, it does not check the current debt of the caller as it does not accrue the debt for both tokens first.

Impact

In the worst case, in low-activity markets, it could happen that debt has not accrued for a long time and the current debt is significantly higher than the current recorded debt in totalDebtAmount. An account with a de-facto negative health ratio if the debt was accrued could still withdraw their collateral NFT instead of having to repay their debt first.

Recommendation

Accrue the debt for both tokens first in LendingPair.withdrawUniPosition.

talegift (Wild Credit) confirmed

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

Impact

In low-activity markets, an account with a de-facto negative health ratio could withdraw their collateral NFT instead of repaying debt first.

What the attacker needed

Low-activity market with unaccrued debt; user has a Uniswap V3 position as collateral

The fix

The function should accrue the debt for both tokens before the health check.

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 a lending protocol, users must keep enough collateral to cover their debt. If interest accumulates but is not recorded, the system may think a user is safer than they really are. This bug lets someone withdraw their collateral even though their actual debt would make them unsafe.

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 cmichel

View all

196 more disclosed reports, best first.

More from Wild Credit 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.