withdrawETH() in GiantPoolBase don’t call _distributeETHRewardsToUserForToken() or _onWithdraw() which would make users to lose their remaining rewards
The withdrawETH function burns the user's LP tokens without first distributing any unclaimed ETH rewards, so a user who withdraws all their LP tokens loses those rewards. An attacker could not gain anything, but any user withdrawing would forfeit their remaining rewards.
unforgiven Follow with 0x4non
Originally disclosed on Code4rena
Submitted by unforgiven, also found by 0x4non
https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantPoolBase.sol#L50-L64 https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantMevAndFeesPool.sol#L180-L193
Function _distributeETHRewardsToUserForToken() is used to distribute remaining reward of user and it’s called in _onWithdraw() of GiantMevAndFeesPool. but function withdrawETH() in GiantPoolBase don’t call either of them and burn user giant LP token balance so if user withdraw his funds and has some remaining ETH rewards he would lose those rewards because his balance set to zero.
Proof of Concept
This is withdrawETH() code in GiantPoolBase:
/// @notice Allow a user to chose to burn their LP tokens for ETH only if the requested amount is idle and available from the contract
/// @param _amount of LP tokens user is burning in exchange for same amount of ETH
function withdrawETH(uint256 _amount) external nonReentrant {
require(_amount >= MIN_STAKING_AMOUNT, "Invalid amount");
require(lpTokenETH.balanceOf(msg.sender) >= _amount, "Invalid balance");
require(idleETH >= _amount, "Come back later or withdraw less ETH");
idleETH -= _amount;
lpTokenETH.burn(msg.sender, _amount);
(bool success,) = msg.sender.call{value: _amount}("");
require(success, "Failed to transfer ETH");
emit LPBurnedForETH(msg.sender, _amount);
}
As you can see it burn user lpTokenETH balance and don’t call either _distributeETHRewardsToUserForToken() or _onWithdraw(). and in function claimRewards() uses lpTokenETH.balanceOf(msg.sender) to calculate user rewards so if user balance get to 0 user won’t get the remaining rewards. These are steps that this bug happens:
user1deposit10ETH into the giant pool andclaimed[user1][lpTokenETH]is20andaccumulatedETHPerLPShareis2.- some time passes and
accumulatedETHPerLPShareset to3. user1unclaimed rewards are10 * 3 - 20 = 10ETH.user1withdraw his10ETH by callingwithdrawETH(10)and contract setlpTokenETHbalance ofuser1to0and transfer10ETH to user.- now if
user1callsclaimRewards()he would get0reward as hislpTokenETHbalance is0.
so users lose their unclaimed rewards by withdrawing their funds.
Tools Used
VIM
Recommended Mitigation Steps
User’s unclaimed funds should be calculated and transferred before any actions that change user’s balance.
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 withdrawETH function burns the user's LP tokens without calling the reward distribution logic that other withdrawal paths use.
Impact
Users who withdraw their LP tokens lose any unclaimed ETH rewards, as the reward calculation later sees a zero balance.
What the attacker needed
User has unclaimed ETH rewards; user withdraws all LP tokens via withdrawETH
The fix
The withdrawETH function should calculate and transfer any unclaimed rewards before burning the user's LP tokens.
How it was found
- User deposits ETH into the giant pool, setting their LP token balance and reward checkpoint.
- Over time the accumulated reward per LP share increases.
- User calls withdrawETH with the full LP token amount.
- The contract burns the LP tokens and transfers the ETH, leaving the user's LP balance at zero.
- When the user later calls claimRewards, the reward calculation uses the now-zero LP balance and returns nothing.
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 this system, users deposit ETH and receive LP tokens that represent their share. Rewards are paid based on how many LP tokens you hold. The withdraw function destroys your LP tokens without first paying out any rewards you have earned but not yet claimed, so those rewards are lost.
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.