Skip to content
Business logic Audit finding Intermediate

paucheTranche state can be set to arbitrary value

The pauseTranche state can be overwritten with a lower borrower tier, so a later liquidation of a lower-tier borrower resets the paused tranche and defeats the withdrawal block for users in higher tranches. An attacker could potentially set pauseTranche to an arbitrary value by self-liquidating, but the judge noted this requires bad debt and is difficult to exploit.

ladboy233 Follow

Originally disclosed on Code4rena

Submitted by ladboy233

https://github.com/code-423n4/2023-11-betafinance/blob/0f1bb077afe8e8e03093c8f26dc0b7a2983c3e47/Omni_Protocol/src/OmniPool.sol#L348

https://github.com/code-423n4/2023-11-betafinance/blob/0f1bb077afe8e8e03093c8f26dc0b7a2983c3e47/Omni_Protocol/src/OmniToken.sol#L180

paucheTranche state can be set to arbitrary value

Proof of Concept

The protocol has this concept of tranche id and borrower tier, the higher borrower tier means higher risk.

Lower borrower tier means lower risk.

When liquidation happens, if the borrowTrueValue is greater than depositTrueValue, which can happen because of the underlying oracle price can change:

if (evalAfter.borrowTrueValue > evalAfter.depositTrueValue) {
	pauseTranche = borrowTier;
	emit PausedTranche(borrowTier);
}

When the pauseTranche id is set to the borrower tier in this line of code, the user that deposited below the paused tranche id should not be able to withdraw / tranche id share because this check is in-place:

require(_trancheId < IOmniPool(omniPool).pauseTranche(), "OmniToken::withdraw: Tranche paused.");

The problem is that the paucheTranche state can be set to arbitrary value.

Suppose a user has borrower tier 10 and borrowTrueValue exceed depositTrueValue, the pauseTranche is set to 10, then a second user has borrower tier 0, he is subject to liquidation as well.

borrowTrueValue exceed depositTrueValue as well.

The pauseTranche is reset to 0 again, which defeats the check of:

require(_trancheId < IOmniPool(omniPool).pauseTranche(), "OmniToken::withdraw: Tranche paused.");

Recommended Mitigation Steps

Change the code to:

if (evalAfter.borrowTrueValue > evalAfter.depositTrueValue) {
	pauseTranche = max(borrowTier, pauseTranche)
	emit PausedTranche(borrowTier);
}

cccz (Judge) commented:

Nice Find!

pauseTranche is used to disallow the user from calling withdraw() to withdraw assets before socializeLoss() is called. As for severity, I’m not so sure it’s a High, need more thought on that.

Ladboy233 (Warden) commented:

I submitted as High because this finding allows user to perform privilege escalation and act as admin to pause arbitrary tranche.

Users can select a tranche and deposit and borrow and liquidation themselves to set pauseTranche to any value.

Unless admin kept a step into to unpause, all other user’s withdraw transaction can revert because of this check.

require(_trancheId < IOmniPool(omniPool).pauseTranche(), "OmniToken::withdraw: Tranche paused.");

cccz (Judge) decreased severity to Medium and commented:

This requires not only that the user can be liquidated, but also that the bad debt arises (there is big gap between the two), so I think it would be very difficult for an attacker to actively exploit this issue to set pauseTranche.

And as TRST-M-1 Users can avoid losses by withdrawing assets before pausing due to bad debt noted, users can withdraw preemptively to prevent socializeLoss() from causing losses.

Users can’t actively arise bad debt, medium likelihood.

Users can withdraw their assets before socialize loss, medium impact.

So consider it medium severity.

allenjlee (BetaFinance) confirmed and commented:

Agree with judge’s assessment, medium severity. There should be no loss to users, and this situation arises in the case only where a higher tranche has bad debt after a lower tranche has bad debt. The worst case scenario, is that one depositor is left with all the bad debt, which is unintended by the protocol but does not cause loss of funds compared to existing protocols — which rely on manual pause intervention, which the protocol also has as we inherit Pausable, so this is medium severity.

We will fix to the latest recommendation, which is using the pauseTranche = borrowTier > pauseTranche ? pauseTranche : borrowTier;


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

Likely the assignment pauseTranche = borrowTier overwrites any existing higher pauseTranche value instead of keeping the maximum.

Impact

The judge rated this medium severity because actively causing bad debt is difficult and users can withdraw before losses are socialised, so there is no direct loss of funds.

What the attacker needed

A borrower is liquidated with bad debt; a lower-tier borrower is later liquidated with bad debt

The fix

The team said they will fix it by keeping the higher of the current and new pauseTranche values.

How it was found

  1. A user with borrower tier 10 is liquidated and borrowTrueValue exceeds depositTrueValue, setting pauseTranche to 10.
  2. A second user with borrower tier 0 is also liquidated with borrowTrueValue exceeding depositTrueValue.
  3. The pauseTranche is reset to 0, defeating the withdrawal check for tranches below 10.

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 protocol, users are grouped into tranches by risk level. When a borrower's debt exceeds their deposit, the protocol pauses that tranche to stop withdrawals until losses are socialised. The bug is that a later liquidation of a lower-risk tranche overwrites the paused tranche with a lower number, so the earlier pause is lost and users in the higher tranche can withdraw again.

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 ladboy233

View all

47 more disclosed reports, best first.

More from Beta Finance 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.