Skip to content
Business logic Audit finding Intermediate

After debt seizure from InsuranceFund , user can dilute all past participants.

After a debt seizure leaves the insurance fund with pending obligations and zero balance, an attacker can deposit a tiny amount to receive an enormous number of shares, diluting earlier liquidity providers. The attacker then takes a much larger share of future profits.

0xliumin Follow

Originally disclosed on Code4rena

Submitted by 0xliumin

https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/InsuranceFund.sol#L56

A user can get a much larger portion of the pool as it recovers from a debt seizure. The intent of the insurance pool seems to be that it could recover from a bad debt event.

Proof of Concept

  1. Alice is the first LP to the insurance pool, and deposits 1e18 shares.
  2. seizeBadDebt is called with 2e18. Now, there are pendingObligations = 1e18, and there is 0 vusd in the insurance fund.
  3. Bob (the attacker) directly transfers 1e18 + 1 vUSD.
  4. Bob calls deposit with 1e18 vUSD. All pending obligations will be settled, but there will only be 1 vUSD left in the pool before Bob’s deposit. Bob receives shares = 1e18 * 1e18 / 1. As a result, Bob will get 1e36 shares, diluting Alice’s share of the pool. Bob will be able to take a much larger share of all future profits from the insurance fund until more bad debt is seized. Bob only provided 2e18 + 1 liqudiity, but received an exponentially larger number of shares than Alice.

Recommended Mitigation Steps

It depends on how you want this to work. You could keep track of the total amount ever contributed by users, and use that for calculations. Or just make staking 1 vUSD = 1 share if the pool total is below the total number of shares.

atvanguard (Hubble) disputed and commented:

Disputing this. It is by design. LPs who were in the insurance fund will be burnt during a bad debt settlement.

JasoonS (judge) decreased severity to Medium


The original report as published on Code4rena, by 0xliumin. 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 share calculation divides by the current pool balance (which can be near zero after a seizure) without accounting for pending obligations or total historical contributions, allowing a small deposit to mint an excessive number of shares.

What the attacker needed

A debt seizure has occurred; attacker can transfer tokens directly; attacker can call deposit

The fix

The report suggests tracking total historical contributions for calculations, or making 1 vUSD equal 1 share when the pool total is below the total number of shares.

How it was found

  1. Alice deposits 1e18 shares as the first liquidity provider.
  2. seizeBadDebt is called with 2e18, leaving pendingObligations = 1e18 and zero vusd in the fund.
  3. Bob directly transfers 1e18 + 1 vUSD to the fund.
  4. Bob calls deposit with 1e18 vUSD, settling pending obligations and leaving only 1 vUSD before his deposit.
  5. Bob receives 1e36 shares, diluting Alice's share of the pool.

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.

An insurance fund is a shared pot where people deposit money and get shares representing their portion. When the fund takes a loss, its balance can drop to zero while it still owes money to the pool. The attacker then deposits a very small amount, but because the fund's balance is near zero, the share calculation gives them a huge number of shares, shrinking everyone else's slice.

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 0xliumin

View all

5 more disclosed reports, best first.

More from Hubble 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.