bringUnusedETHBackIntoGiantPool in GiantMevAndFeesPool can be used to steal LPTokens
The function bringUnusedETHBackIntoGiantPool does not verify that the provided staking funds vaults are legitimate, allowing an attacker to supply fake vault contracts. The attacker can then use these fake vaults to transfer real LP tokens out of the GiantMevAndFeesPool contract.
Submitted by datapunk
real LPTokens can be transferred out of GiantMevAndFeesPool through fake _stakingFundsVaults provided by an attacker. https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/liquid-staking/GiantMevAndFeesPool.sol#L126
Proof of Concept
bringUnusedETHBackIntoGiantPool takes in _stakingFundsVaults, _oldLPTokens, _newLPTokens and rotate _amounts from old to new tokens. The tokens are thoroughly verified by burnLPForETH in ETHPoolLPFactory.
However, theres is no checking for the validity of _stakingFundsVaults, nor the relationship between LPTokens and _stakingFundsVaults. Therefore, an attacker can create fake contracts for _stakingFundsVaults, with burnLPTokensForETH, that takes LPTokens as parameters. The msg.sender in burnLPTokensForETH is GiantMevAndFeesPool, thus the attacker can transfer LPTokens that belongs to GiantMevAndFeesPool to any addresses it controls.
Recommended Mitigation Steps
Always passing liquid staking manager address, checking its real and then requesting either the savETH vault or staking funds vault is a good idea to prove the validity of vaults.
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
The function does not validate that the provided staking funds vaults are legitimate and have a valid relationship with the LP tokens.
Impact
An attacker could steal real LP tokens from the GiantMevAndFeesPool contract.
What the attacker needed
Attacker can deploy contracts; attacker can call bringUnusedETHBackIntoGiantPool
The fix
The function should validate the staking funds vaults by checking the liquid staking manager address and verifying the vaults' legitimacy.
How it was found
- Create fake contracts for _stakingFundsVaults with a burnLPTokensForETH function that takes LPTokens as parameters.
- Call bringUnusedETHBackIntoGiantPool with the fake vaults and the target LP tokens.
- The fake vault's burnLPTokensForETH is called with msg.sender as GiantMevAndFeesPool, allowing transfer of LP tokens to attacker-controlled addresses.
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 function that moves tokens between pools trusts the addresses it is given without checking if they are real. An attacker can give it fake addresses that pretend to be real pools, and because the function trusts them, it lets the attacker take real tokens. This is like a bank teller accepting a fake ID and handing over someone else's money.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.