Skip to content
Business logic Audit finding Intermediate

BBLiquidation::_liquidateUser liquidator can bypass protocol fee on liquidation by returning returnedShare == borrowShare

A liquidator can bypass the protocol fee on liquidation by returning only the borrow amount after seizing collateral with a bonus, keeping the excess. This allows the liquidator to steal the fee that would otherwise go to the protocol.

cergyk Follow with duc

Originally disclosed on Sherlock

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

Found by

cergyk, duc

Summary

When a liquidator liquidates a position on BigBang/Singularity market, they do not get the full liquidationBonus amount, but a callerShare which depends on the efficiency of the liquidation.

However since this share is taken after the liquidator has swapped the seized collateral to an asset amount, the liquidator can simply choose to return enough asset to repay the borrow, reducing the extra amount to zero.

In that case the protocol fee and the caller share would be zero, but the liquidator has seized the full liquidation bonus during the swap.

Vulnerability Detail

We can see that after the collateral has been seized from the liquidatee, the full amount of collateral with the liquidation bonus is sent to an arbitrary liquidationReceiver during _swapCollateralWithAsset:

https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/bigBang/BBLiquidation.sol#L262-L263

https://github.com/sherlock-audit/2024-02-tapioca/blob/main/Tapioca-bar/contracts/markets/bigBang/BBLiquidation.sol#L152-L159

The liquidator can choose to send back only borrowAmount of asset, effectively keeping excess collateral to himself

Impact

Liquidator steals the due fee from protocol during liquidation

Code Snippet

Tool used

Manual Review

Recommendation

Consider adding a slippage control to the swap executed by the liquidator (e.g the liquidator must return at least 105% of borrowAmount, when seizing 110% of equivalent collateral)

Discussion

cryptotechmaker

Medium. The issue seems to be valid. However the user is not able to steal the full collateral, but only the bonus part, out of which he would have taken 90% anyway.

nevillehuang

request poc

sherlock-admin3

PoC requested from @CergyK

Requests remaining: 3

CergyK

Poc shared in a private repository

The poc demonstrates how a malicious liquidator can bypass protocol fees which as @cryptotechmaker noted are at least 10% of liquidation bonus, but can be 20% in the worst case.

Since no prerequisite is needed to do that on any liquidation, and the loss of fees incurred on the protocol is unbounded, this warrants high severity IMO

CergyK

Coincidentally, the POC also demonstrates #32, since the price move used puts the user in bad debt but liquidation succeeds

nevillehuang

@cryptotechmaker Did you have a chance to look at this? I'm not sure if bypassing fees is high severity, I think I am inclined to keep medium

cryptotechmaker

Yes, it's a valid issue @nevillehuang

sherlock-admin4

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

CergyK

Escalate

This should be of high severity, as demonstrated, it enables to bypass protocol fees on any liquidation. For reference, issue #148 which claims freezing of the same protocol fees is rated as high

sherlock-admin2

Escalate

This should be of high severity, as demonstrated, it enables to bypass protocol fees on any liquidation. For reference, issue #148 which claims freezing of the same protocol fees is rated as high

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

nevillehuang

@CergyK Fair enough, the impact is similar to #148 so could be high severity (albeit protocol fees are not locked, just completely lost)

cvetanovv

I agree with the escalation. The impact is the same as #148.

cvetanovv

Planning to accept the escalation and make this issue a valid High.

Evert0x

Result: High Has Duplicates

sherlock-admin4

Escalations have been resolved successfully!

Escalation status:

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

Root cause

Likely the lack of slippage control on the swap allows the liquidator to return only the borrow amount, making the caller share and protocol fee zero while retaining the bonus.

What the attacker needed

None

The fix

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

How it was found

  1. Liquidator liquidates a position on BigBang/Singularity market.
  2. Collateral with liquidation bonus is sent to an arbitrary liquidationReceiver during _swapCollateralWithAsset.
  3. Liquidator swaps the seized collateral to an asset amount.
  4. Liquidator returns only borrowAmount of asset, keeping excess collateral.
  5. Protocol fee and caller share become zero, but liquidator has seized the full liquidation bonus.

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.

When a borrower is liquidated, the liquidator gets a bonus for repaying the debt. The protocol also takes a fee from that bonus. Here, the liquidator can choose to return only the exact debt amount after swapping the seized collateral, so the fee calculation sees no extra value and the fee becomes zero, while the liquidator keeps the bonus.

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.