Skip to content
Business logic Audit finding Advanced

wrong calcLiquidityHoldings that leads to dead fund in the Pool

The Pool contract mints one kind of LP token both for ordinary liquidity providers and for Synth debt positions, so the two are mixed in the same accounting. An attacker could mint Synth against a pool, then withdraw and burn in an order that leaves the pool holding a large amount of the paired token with no LP holders left to claim it.

jonah1005 Follow

Originally disclosed on Code4rena

Submitted by jonah1005

The lptoken minted by the Pool contract is actually the mix of two types of tokens. One is the original lptokens user get by calling addForMember. This lpToken is similar to lp of Uniswap, Crv, Sushi, … etc. The other one is the debt-lp token the Synth contract will get when the user calls mintSynth. The Synth contract can only withdraw Sparta for burning debt-lp. Mixing two types of lp would raise several issues.

LP user would not get their fair share when they burn the lP.

  1. Alice adds liquidity with Sparta 1000 and token B 1000 and create a new Pool.
  2. Bob mint Synth with 1000 Sparta and get debt.
  3. Alice withdraw all lp Token
  4. Bob burn all Synth.

The pool would end up left behind a lot of token B in the Pool while there’s no lp holder.

I would say this is a high-risk vulnerability since it pauses unspoken risks and losses for all users (all the time)

The logic of burn original lp and burn debt-lp.

I do not know whether this is the team’s design choice or its composite with a series of bugs. If this is the original design, I do not come up with a fix. It’s a bit similar to the impermanent loss. However, the loss would be left behind in the Pool. This is more complicated and maybe worse than the impermanent loss. If this is the design choice, I think it’s worth emphasize and explain to the users.

verifyfirst (Spartan) confirmed and disagreed with severity:

We are in discussion of a viable solution to limit the effects of a bank run. One example is limiting the minted synths based on the depth of its underlying pool.

SamusElderg (Spartan) commented:

LP units are only used for accounting; even if they were drained to zero or vice versa on the synth contract; they would result in the same redemption value when burning. Hence the risk is low; however there is already discussions on implementing controls to synths including a maximum synthSupply vs tokenDepth ratio to prevent top-heavy synths ontop of the pools which isn’t really specific to the warden’s scenario; however does help limit those ‘unknowns’ that the warden addressed.

The original report as published on Code4rena, by jonah1005. 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 pool uses a single LP token for both ordinary liquidity and Synth debt, so the two claims are not accounted for separately.

Impact

The pool could be left holding a large amount of the paired token with no LP holder to claim it, which the reporter frames as a loss for all users, though the team argued LP units are only for accounting and the risk is low.

What the attacker needed

Ability to add liquidity; ability to mint Synth

The fix

The team said it was discussing controls such as limiting minted synths based on the depth of the underlying pool, but no concrete fix is stated.

How it was found

  1. Alice adds liquidity with Sparta and token B and creates a new Pool.
  2. Bob mints Synth with Sparta and receives debt.
  3. Alice withdraws all her LP tokens.
  4. Bob burns all his Synth.

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.

A liquidity pool holds two tokens and gives people a receipt token showing their share. Here the same receipt token is also handed out when someone borrows a synthetic asset against the pool. Because both groups share one receipt, the order in which people join and leave can leave tokens stranded in the pool with nobody owning them.

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 jonah1005

View all

39 more disclosed reports, best first.

More from Spartan Protocol 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.