ConcentratedLiquidityPool : secondsPerLiquidity should be modified whenever pool liquidity changes
The secondsPerLiquidity value is not updated when pool liquidity changes in the mint and burn functions, so it becomes stale. An attacker could exploit this to cause incorrect accounting of time-weighted liquidity, potentially leading to unfair distribution of rewards or other financial discrepancies.
Submitted by hickuphh3
Impact
secondsPerLiquidity is updated as such: secondsPerLiquidity += uint160((diff << 128) / liquidity); where diff = timestamp - uint256(lastObservation). Hence, whenever liquidity changes, secondsPerLiquidity should be updated prior to the change.
In particular, this affects the mint() and burn() functions, in the case where liquidity changes when lowerTick <= currentTick < upperTick.
In fact, the latest secondsPerLiquidity value should be calculated and used in Ticks.insert(). For comparison, notice how UniswapV3 fetches the latest value by calling observations.observeSingle() in its _updatePosition() function.
Recommended Mitigation Steps
The secondsPerLiquidity increment logic should be applied prior to liquidity addition in mint() and removal in burn().
// insert logic before these lines in mint()
unchecked {
if (priceLower < currentPrice && currentPrice < priceUpper) liquidity += uint128(_liquidity);
}
nearestTick = Ticks.insert(
ticks,
feeGrowthGlobal0,
feeGrowthGlobal1,
secondsPerLiquidity, // should calculate and use latest secondsPerLiquidity value
...
);
// insert logic before before these lines in burn()
unchecked {
if (priceLower < currentPrice && currentPrice < priceUpper) liquidity -= amount;
}
sarangparikh22 (Sushi) disputed:
The secondsPerLiquidity is same, changing the order of that will not affect anything, since it is not getting calculated at the mint or burn function.
@sarangparikh22 (Sushi), could you please elaborate on why this isn’t an issue?
sarangparikh22 (Sushi) confirmed:
@alcueca (judge) my apologies, this is an issue. I could confirm this.
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
Impact
This could lead to incorrect secondsPerLiquidity values, potentially causing unfair reward distribution or accounting errors.
What the attacker needed
Liquidity change within tick range
The fix
The secondsPerLiquidity increment logic should be applied before liquidity addition in mint() and removal in burn().
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 a liquidity pool, secondsPerLiquidity tracks how long liquidity has been provided, weighted by the amount. If the pool's liquidity changes without updating this value first, the record becomes wrong. This could let someone manipulate the system to get more rewards than they deserve.
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.