`Fontaine` never stops the flows to the tax and recipient, so the buffer component of the flows will be lost
The Fontaine contract never stops the Superfluid flows it creates, so the 4-hour deposit buffer reserved for liquidations is never reclaimed. The recipient and tax pool therefore lose those funds.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-11-superfluid-locking-contract-judging/issues/36
Found by
0x73696d616f
Summary
Superfluid flows reserve 4 hours of the stream flow rate as a buffer for liquidations, and returns this when the flow is closed.
However, Fontaine::initialize() never actually stops the flows, which means the deposit buffer will never be reclaimed, taking the recipient and the tax pool the loss.
Root Cause
In Fontaine::initialize(), the flows are never stopped, which means the buffer will not be returned.
Internal pre-conditions
None.
External pre-conditions
None.
Attack Path
- User unlocks their
Fluidfrom theLockerby callingFluidLocker::unlock()with a non null unlocking period.
Impact
The recipient and the tax distribution pool take the loss as they do not receive all their funds (the deposit buffer is never sent to them).
PoC
Add the following logs to Fontaine.sol and run forge test --mt testVestUnlock -vvvv. Alice sends 10_000e18 to the fontaine, but only 9996.8e18 are left in the fontaine as a part of them are reserved for the buffer which will never be collected back.
function initialize(address unlockRecipient, int96 unlockFlowRate, int96 taxFlowRate) external initializer {
// Ensure recipient is not a SuperApp
if (ISuperfluid(FLUID.getHost()).isApp(ISuperApp(unlockRecipient))) revert CANNOT_UNLOCK_TO_SUPERAPP();
console2.log("fontaine balance pre distributeFlow", FLUID.balanceOf(address(this)));
// Distribute Tax flow to Staker GDA Pool
FLUID.distributeFlow(address(this), TAX_DISTRIBUTION_POOL, taxFlowRate);
console2.log("fontaine balance pre createFlow", FLUID.balanceOf(address(this)));
// Create the unlocking flow from the Fontaine to the locker owner
FLUID.createFlow(unlockRecipient, unlockFlowRate);
console2.log("fontaine balance after createFlow", FLUID.balanceOf(address(this)));
}
Mitigation
Add a way to stop the flow and receive the deposit back.
Discussion
0xPilou
Fix for this issue is included in the following PR : https://github.com/superfluid-finance/fluid/pull/8
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/superfluid-finance/fluid/pull/8
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 contract lacks a function to stop the flows and reclaim the deposit buffer.
Impact
The recipient and the tax distribution pool take the loss as they do not receive all their funds (the deposit buffer is never sent to them).
What the attacker needed
User unlocks Fluid with a non-null unlocking period
The fix
The protocol team fixed this issue in the following PRs/commits.
How it was found
- User unlocks their Fluid from the Locker by calling FluidLocker::unlock() with a non-null unlocking period.
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.
Superfluid streams money continuously and holds back a small deposit as a buffer for liquidations. The Fontaine contract starts these streams but never stops them, so the buffer is never returned. As a result, the recipient and tax pool receive less than they should.
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.