Skip to content
Business logic Audit finding Intermediate

Withdrawing wrong LPToken from GiantPool leads to loss of funds

The GiantPool withdrawal function burns GiantLP tokens and returns LP tokens without checking that the requested LP token was one the pool actually accepted in exchange for staking ETH. An attacker could send a worthless self-created LP token to the pool and trick a victim into withdrawing it, burning GiantLP tokens that map 1:1 to ETH, and could also break internal accounting so some LP tokens become stuck.

aphak5010 Follow with datapunk, arcoun and 3 others

Originally disclosed on Code4rena

Submitted by aphak5010, also found by datapunk, arcoun, wait, unforgiven, and yixxas

The GiantPoolBase.withdrawLPTokens function (https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantPoolBase.sol#L69) allows to withdraw LP tokens from a GiantPool by burning an equal amount of GiantLP.

This allows a user to handle the LP tokens directly without the need for a GiantPool as intermediary.

It is not checked however whether the LP tokens to be withdrawn were transferred to the GiantPool in exchange for staking ETH.

I.e. whether the LP token are of any value.

There are two issues associated with this behavior.

  1. A malicious user can create and mint his own LP Token and send it to the GiantPool. Users that want to withdraw LP tokens from the GiantPool can then be tricked into withdrawing worthless attacker LP tokens, thereby burning their GiantLP tokens that are mapped 1:1 to ETH. (-> loss of funds)
  2. This can also mess up internal accounting logic. For every LP token that is owned by a GiantPool there should be a corresponding GiantLP token. Using the described behavior this ratio can be broken such that there are LP token owned by the GiantPool for which there is no GiantLP token. This means some LP token cannot be transferred from the GiantPool and there will always be some amount of LP token “stuck” in the GiantPool.

Proof of Concept

  1. The attacker deploys his own LPToken contract and sends a huge amount of LP tokens to the GiantPool to pass the check in GiantPoolBase._assertUserHasEnoughGiantLPToClaimVaultLP (https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantPoolBase.sol#L95).
  2. The attacker tricks Bob into withdrawing the malicious LP tokens from the GiantPool (https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantPoolBase.sol#L69).
  3. Bob’s GiantLP tokens are burnt and he receives worthless LP tokens.

The same issue exists for the GiantSavETHVaultPool.withdrawDETH function. But in this case, the victim must also provide a wrong savETHVault address which makes this issue less likely to be exploited.

Tools Used

VSCode

Recommended Mitigation Steps

The GiantPool should store information about which LP tokens it receives for staking ETH. When calling the GiantPoolBase.withdrawLPTokens function it can then be checked if the LP tokens to be withdrawn were indeed transferred to the GiantPool in exchange for staking ETH.

vince0656 (Stakehouse) confirmed


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

Impact

A victim could lose GiantLP tokens that map 1:1 to ETH in exchange for worthless tokens, and the pool's accounting could be broken so some LP tokens become stuck; the related savETHVault variant is less likely because the victim must also supply a wrong vault address.

What the attacker needed

Attacker can deploy a token contract; victim withdraws attacker-chosen LP token

The fix

The GiantPool should record which LP tokens it received for staking ETH and check on withdrawal that the requested LP token is one of them.

How it was found

  1. The attacker deploys their own LP token contract and sends a large amount of it to the GiantPool so the balance check passes.
  2. The attacker tricks Bob into withdrawing the malicious LP tokens from the GiantPool.
  3. Bob's GiantLP tokens are burnt and he receives the worthless LP tokens.

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 tokens on behalf of users and gives them a receipt token in return. Here the pool let anyone hand back a receipt and receive whatever token they named, without checking that the pool ever held that token. So a scammer could plant a fake, worthless token and persuade someone to swap their valuable receipt for it.

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 aphak5010

View all

6 more disclosed reports, best first.

More from LSD Network - Stakehouse 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.