Skip to content
Business logic Audit finding Intermediate

Malicious users can provide liquidity on behalf of others to keep others in the liquidity cooldown

The mint function allows a user to add liquidity on behalf of another address, which updates that address's lastLiquidityAddTimestamp. A malicious user can repeatedly add a tiny amount of liquidity for a victim, keeping the victim in the liquidity cooldown and preventing them from removing their own liquidity.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz, also found by 0x52

In the AlgebraPool contract, when the user provides liquidity via the mint function, the lastLiquidityAddTimestamp is updated to the current time.

      (_position.liquidity, _position.lastLiquidityAddTimestamp) = (
        liquidityNext,
        liquidityNext > 0 ? (liquidityDelta > 0 ? _blockTimestamp() : lastLiquidityAddTimestamp) : 0
      );

Later when the user removes the liquidity via burn function, the transaction will revert if the current time is less than lastLiquidityAddTimestamp + _liquidityCooldown.

      if (liquidityDelta < 0) {
        uint32 _liquidityCooldown = liquidityCooldown;
        if (_liquidityCooldown > 0) {
          require((_blockTimestamp() - lastLiquidityAddTimestamp) >= _liquidityCooldown);
        }
      }

liquidityCooldown is max 1 day. However, in the mint function, users can provide liquidity on behalf of other users, which also means that malicious users can keep other users on liquidity cooldown forever by providing a little bit of liquidity on behalf of other users, thus preventing other users from removing liquidity.

  function mint(vladyan18
    address sender,
    address recipient,  // @audit: users can provide liquidity on behalf of other users
    int24 bottomTick,
    int24 topTick,
    uint128 liquidityDesired,
    bytes calldata data
  )
...
      (, int256 amount0Int, int256 amount1Int) = _updatePositionTicksAndFees(recipient, bottomTick, topTick, int256(liquidityActual).toInt128());

Proof of Concept

AlgebraPool.sol#L226-L231 AlgebraPool.sol#L513-L523

Recommended Mitigation Steps

Consider allowing users to provide liquidity only for themselves, or setting liquidityCooldown to 0.

vladyan18 (QuickSwap & StellaSwap) confirmed

sameepsi (QuickSwap & StellaSwap) disagreed with severity and commented:

This is a valid issue but the severity should be medium. This can be easily mitigated by simply setting up cool down period to 0.

0xean (judge) commented:

See comment on issue #83.

Issue is valid and leads to locking of funds, High severity is warranted. Turning cool down to 0 would work, but has other consequences for JIT liquidity.


The original report as published on Code4rena, by cccz. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 mint function accepts a recipient address different from the sender, so anyone can update another user's lastLiquidityAddTimestamp and extend their cooldown.

Impact

A malicious user could indefinitely prevent other users from removing their liquidity, effectively locking their funds, though the report notes the cooldown can be set to zero as a mitigation.

What the attacker needed

Victim has liquidity in the pool; attacker can call mint repeatedly

The fix

The mint function should only allow users to provide liquidity for themselves, or the liquidityCooldown should be set to zero.

How it was found

  1. Identify a victim who has liquidity in the pool.
  2. Call mint with the victim as recipient and a very small liquidity amount.
  3. Repeat the mint call before the cooldown expires to keep resetting the victim's lastLiquidityAddTimestamp.
  4. The victim's burn transaction reverts because the cooldown has not elapsed.

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 this liquidity pool, after you add liquidity, you must wait for a cooldown period before you can remove it. The code lets anyone add liquidity for any other address, and doing so resets that address's cooldown timer. An attacker can keep resetting the timer with tiny deposits, so the victim can never take their money out.

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.

More by cccz

View all

104 more disclosed reports, best first.

More from QuickSwap and StellaSwap contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.