Reentrancy vulnerability in GiantMevAndFeesPool.withdrawETH
The withdrawETH function in GiantMevAndFeesPool calls an external contract before updating the idleETH balance, allowing a reentrant call to claimRewards that inflates rewards. An attacker could exploit this to receive more rewards than deserved.
Submitted by cccz
GiantMevAndFeesPool.withdrawETH calls lpTokenETH.burn, then GiantMevAndFeesPool.beforeTokenTransfer, followed by a call to _distributeETHRewardsToUserForToken sends ETH to the user, which allows the user to call any function in the fallback. While GiantMevAndFeesPool.withdrawETH has the nonReentrant modifier, GiantMevAndFeesPool.claimRewards does not have the nonReentrant modifier. When GiantMevAndFeesPool.claimRewards is called in GiantMevAndFeesPool.withdrawETH, the idleETH is reduced but the ETH is not yet sent to the user, which increases totalRewardsReceived and accumulatedETHPerLPShare, thus making the user receive more rewards when calling GiantMevAndFeesPool.claimRewards.
Proof of Concept
Recommended Mitigation Steps
Change to
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);
+ idleETH -= _amount;
(bool success,) = msg.sender.call{value: _amount}("");
require(success, "Failed to transfer ETH");
emit LPBurnedForETH(msg.sender, _amount);
}
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 state variable idleETH is updated after the external call, violating the checks-effects-interactions pattern, and claimRewards lacks a reentrancy guard.
Impact
The user could receive more rewards than they are entitled to.
What the attacker needed
User has LP tokens; Contract has idleETH
How it was found
- Call withdrawETH with a valid amount.
- During the ETH transfer, reenter claimRewards.
- Observe increased rewards due to inflated 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.
This is a reentrancy bug in a smart contract. When a contract sends Ether to a user, the user's contract can run code that calls back into the original contract before the first function finishes. Here, the withdraw function updates a balance after sending Ether, so the user can call claimRewards in between and get extra rewards.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.