Skip to content
Business logic Audit finding Intermediate

BBLiquidation/SGLLiquidation::_updateBorrowAndCollateralShare liquidator can bypass bad debt handling to ensure whole liquidation reward

The liquidation function allows a liquidator to set a small maximum repay amount, bypassing the bad debt handling that would otherwise reduce the liquidation reward. This lets the liquidator receive the full reward on a partial liquidation while leaving the protocol with bad debt.

cergyk Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-02-tapioca-judging/issues/32

Found by

cergyk

Summary

When handling liquidation in BigBang and Singularity market, the protocol ensures that the liquidatee has enough collateral to cover for the liquidation and reward. If that's not the case, then the reward for the liquidator is shrunk proportionally to the bad debt incurred by the protocol.

However the liquidator can simply choose to bypass this protection by setting a max repay amount small enough so it can be covered by the collateral of the liquidatee. This enables the liquidator to get full reward on a partial liquidation, and leaves the protocol with only bad debt

Vulnerability Detail

We can see that some logic for handling bad debt is implemented here when collateralPartInAsset < borrowAmountWithBonus

However the liquidator can reduce the amount to repay arbitrarily by setting the maxBorrowPart parameter.

Thus the liquidator can always choose to execute the second branch, ensuring full reward.

Impact

The protocol incurs more bad debt than due because liquidator can bypass bad debt protection mechanism

Code Snippet

Tool used

Manual Review

Recommendation

Ensure a minimal repay amount in order for the liquidation to always make the account solvent, this would make it impossible for the liquidator to reduce the repay amount arbitrarily

Discussion

cryptotechmaker

Invalid until a PoC is provided. collateralPartInAsset is represented by userCollateralShare

cryptotechmaker

Also 2nd branch is still using borrowPartWithBonus which is conditioned by maxBorrowPart

sherlock-admin4

1 comment(s) were left on this issue during the judging contest.

takarez commented:

seem valid medium to me; medium(6)

nevillehuang

request poc

sherlock-admin3

PoC requested from @CergyK

Requests remaining: 5

CergyK

Shared poc on a private repo

The poc demonstrates that when a user will be causing bad debt to the protocol if liquidated fully, a liquidator can still liquidate partially and leave the account in a worse shape than initially

maarcweiss

Thanks @CergyK Could you please invite: maarcweiss, cryptotechmaker and 0xrektora to the repo? Thanks.

sherlock-admin4

The protocol team fixed this issue in PR/commit https://github.com/Tapioca-DAO/Tapioca-bar/pull/379.

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

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

The protocol incurs more bad debt than necessary because the liquidator can bypass the bad debt protection and still receive the full reward.

What the attacker needed

A liquidatable account with bad debt; liquidator can call liquidation

The fix

The protocol team fixed this issue in a pull request.

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, if a borrower's collateral is worth less than their debt, a liquidator can repay part of the debt and earn a reward. Normally, if the collateral cannot cover both the debt and the reward, the reward is reduced. Here, the liquidator can choose to repay only a small amount, so the collateral covers that small amount plus the full reward, and the remaining debt becomes bad debt for the protocol.

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 cergyk

View all

29 more disclosed reports, best first.

More from Tapioca

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.