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.
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:
- giant pool has 100
idleETH. - with function
batchDepositETHForStaking()users stake 80ETHand the new value ofidleETHwould be20and contract LP Token balance increase by 80. - the 80 newly staked ETH is not yet staked in
stakehouse. - with function
bringUnusedETHBackIntoGiantPool()users bring back those 80ETHfrom Vaults to giant pool and burn giant pool LP tokens and then giant pool have 100 idle ETH but becauseidleETHvalue don’t get increase it still would show20. - 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
idleETHhas 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
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
- The giant pool has 100 idleETH.
- Users stake 80 ETH via batchDepositETHForStaking(), reducing idleETH to 20 and increasing LP token balance by 80.
- The 80 ETH is not yet staked in stakehouse.
- Users call bringUnusedETHBackIntoGiantPool() to return the 80 ETH to the giant pool and burn LP tokens.
- The giant pool now holds 100 ETH but idleETH still shows 20.
- 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.