GiantPool batchRotateLPTokens function: Minimum balance for rotating LP Tokens should by dynamically calculated
The batchRotateLPTokens function in two GiantPool contracts requires a fixed minimum LP token balance of 0.5 ether, which does not scale with total pool size and can prevent legitimate users from calling the function. An attacker could not exploit this directly, but it is a design flaw that may block intended operations.
Submitted by aphak5010
https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantSavETHVaultPool.sol#L127 https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantMevAndFeesPool.sol#L116 https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantPoolBase.sol#L22
The GiantSavETHVaultPool and GiantMevAndFeesPool both have a batchRotateLPTokens function that allows to move staked ETH to another key. Both functions require that the GiantLP balance of the sender is >=0.5 ether.
The reason for this is that there is a common interest needed in order to rotate LP Tokens. The way this is implemented right now does not serve this purpose and even makes the functions unable to be called in some cases.
The MIN_STAKING_AMOUNT for the GiantPools is 0.001 ether (https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantPoolBase.sol#L22). So a user should expect that this amount is sufficient to properly use the contract. However, even if there are multiple users paying into the GiantPool, they might not reach the 0.5 ETH threshold to call the function. So even if they would use some kind of multisig wallet to call the batchRotateLPTokens function, it would not be possible.
Also the threshold does not scale.
Imagine that User A puts 100 ETH into the GiantPool. Another User B puts 0.5 ETH into the GiantPool. Can we speak of “common interest” when User B wants to rotate the LP Tokens?
Tools Used
VSCode
Recommended Mitigation Steps
My suggestion is to use a formula like:
require(lpTokenETH.balanceOf(msg.sender) >= (lpTokenETH.totalSupply() / CONSTANT_VALUE)).
Where you can choose a CONSTANT_VALUE like 20 or 50.
This properly scales the required amount and helps mitigate both scenarios.
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
Impact
The fixed threshold may prevent users from calling batchRotateLPTokens even when they have a legitimate interest, and it does not scale with pool size, potentially allowing a small holder to rotate tokens when they shouldn't.
What the attacker needed
None
The fix
The threshold should be calculated dynamically as a fraction of the total LP token supply, for example using a constant divisor like 20 or 50.
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.
In some smart contracts, certain actions require you to hold a minimum amount of a token. Here, the minimum is fixed at 0.5 ether, but the total pool can be much larger or smaller. This means small users might never reach the threshold, and large users could easily meet it even if they don't represent the majority.
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.