Skip to content
Business logic Audit finding Intermediate

Fund lose in function bringUnusedETHBackIntoGiantPool() of GiantSavETHVaultPool ETH gets back to giant pool but the value of idleETH don’t increase

The function bringUnusedETHBackIntoGiantPool() returns unused ETH to the giant pool but fails to increase the idleETH counter, so the contract's accounting no longer matches its actual ETH balance. As a result, the returned ETH cannot be used for future staking or withdrawals, effectively locking those funds.

unforgiven Follow

Originally disclosed on Code4rena

Submitted by unforgiven

https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantSavETHVaultPool.sol#L133-L157 https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantPoolBase.sol#L24-L25

Variable idleETH in giant pools is storing total amount of ETH sat idle ready for either withdrawal or depositing into a liquid staking network and whenever a deposit or withdraw happens contract adjust the value of idleETH of contract, but in function bringUnusedETHBackIntoGiantPool() which brings unused ETH from savETH vault to giant pool the value of idleETH don’t get increased which would cause those ETH balance to not be accessible for future staking or withdrawing.

Proof of Concept

This is bringUnusedETHBackIntoGiantPool() code in GiantSavETHVaultPool():

    /// @notice Any ETH that has not been utilized by a savETH vault can be brought back into the giant pool
    /// @param _savETHVaults List of savETH vaults where ETH is staked
    /// @param _lpTokens List of LP tokens that the giant pool holds which represents ETH in a savETH vault
    /// @param _amounts Amounts of LP within the giant pool being burnt
    function bringUnusedETHBackIntoGiantPool(
        address[] calldata _savETHVaults,
        LPToken[][] calldata _lpTokens,
        uint256[][] calldata _amounts
    ) external {
        uint256 numOfVaults = _savETHVaults.length;
        require(numOfVaults > 0, "Empty arrays");
        require(numOfVaults == _lpTokens.length, "Inconsistent arrays");
        require(numOfVaults == _amounts.length, "Inconsistent arrays");
        for (uint256 i; i < numOfVaults; ++i) {
            SavETHVault vault = SavETHVault(_savETHVaults[i]);
            for (uint256 j; j < _lpTokens[i].length; ++j) {
                require(
                    vault.isDETHReadyForWithdrawal(address(_lpTokens[i][j])) == false,
                    "ETH is either staked or derivatives minted"
                );
            }

            vault.burnLPTokens(_lpTokens[i], _amounts[i]);
        }
    }

As you can see it checks that ETH is available in savETH vault and then calls to burnLPTokens() to burn savETH LP tokens and bring unused ETH to giant pool address, this would increase giant pool ETH balance but code don’t increase the idleETH value so contract would lose tracking of real idle ETH balance of contract. because the vaule of idleETH is used when withdrawing or depositing into savETH vaults so the contract can’t reuse the returned ETH. these are the steps that cause this bug to happen:

  1. giant pool has 100 idleETH.
  2. with function batchDepositETHForStaking() users stake 80 ETH and the new value of idleETH would be 20 and contract LP Token balance increase by 80.
  3. the 80 newly staked ETH is not yet staked in stakehouse.
  4. with function bringUnusedETHBackIntoGiantPool() users bring back those 80 ETH from Vaults to giant pool and burn giant pool LP tokens and then giant pool have 100 idle ETH but because idleETH value don’t get increase it still would show 20.
  5. the extra 80 ETH would returned to giant pool wouldn’t be accessible for withdrawing to users or depositing into Vaults because in withdrawing or depositing into Vaults the value of idleETH has been used to know the amount of idle ETH in giant pool and because the value doesn’t show the correct amount so the extra amount of ETH wouldn’t be lost.

Tools Used

VIM

Recommended Mitigation Steps

Contract should correctly update value of idleETH in different actions because withdraw and deposit logics depend on it.

vince0656 (Stakehouse) confirmed


The original report as published on Code4rena, by unforgiven. 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 function bringUnusedETHBackIntoGiantPool() does not update the idleETH state variable after receiving ETH back from savETH vaults.

Impact

The returned ETH becomes inaccessible for future staking or withdrawals, effectively locking those funds in the contract.

What the attacker needed

Giant pool has idle ETH; users have staked ETH via batchDepositETHForStaking; the staked ETH is not yet staked in stakehouse; users call bringUnusedETHBackIntoGiantPool

The fix

The contract should correctly update the idleETH value in bringUnusedETHBackIntoGiantPool() to reflect the returned ETH.

How it was found

  1. The giant pool has 100 idleETH.
  2. Users stake 80 ETH via batchDepositETHForStaking(), reducing idleETH to 20 and increasing LP token balance by 80.
  3. The 80 ETH is not yet staked in stakehouse.
  4. Users call bringUnusedETHBackIntoGiantPool() to return the 80 ETH to the giant pool and burn LP tokens.
  5. The giant pool now holds 100 ETH but idleETH still shows 20.
  6. The extra 80 ETH cannot be withdrawn or deposited into vaults because those actions rely on idleETH.

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 smart contract keeps a tally called idleETH to track how much ETH is available for users to withdraw or stake. When ETH is returned to the pool, the tally is not updated, so the contract thinks it has less ETH than it really does. That extra ETH becomes stuck because the contract only lets users withdraw or stake based on the tally.

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 unforgiven

View all

50 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.