Skip to content
Business logic Audit finding Intermediate

withdraw timelock can be circumvented

The withdraw timelock could be bypassed by calling the withdraw function twice: first with the full balance to set a lock, then with zero amount to reset the unlock timestamp to the current time. This allowed a user to withdraw their entire deposit immediately without waiting for the lock period.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

One can withdraw the entire PrizePool deposit by circumventing the timelock. Assume the user has no credits for ease of computation:

  • user calls withdrawWithTimelockFrom(user, amount=userBalance) with their entire balance. This “mints” an equivalent amount of timelock and resets _unlockTimestamps[user] = timestamp = blockTime + lockDuration.
  • user calls withdrawWithTimelockFrom(user, amount=0) again but this time withdrawing 0 amount. This will return a lockDuration of 0 and thus unlockTimestamp = blockTime. The inner _mintTimelock now resets _unlockTimestamps[user] = unlockTimestamp
  • As if (timestamp <= _currentTime()) is true, the full users amount is now transferred out to the user in the _sweepTimelockBalances call.

Users don’t need to wait for their deposit to contribute their fair share to the prize pool. They can join before the awards and leave right after without a penalty which leads to significant issues for the protocol. It’s the superior strategy but it leads to no investments in the strategy to earn the actual interest.

Recommend that the unlock timestamp should be increased by duration each time, instead of being reset to the duration.

asselstine (PoolTogether) confirmed:

Mitigation:

If a user’s timelock balance is non-zero, the prize strategy rejects the ticket burn.

The original report as published on Code4rena, by cmichel. 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 unlock timestamp was reset to the current time when a zero-amount withdrawal was made, instead of being extended by the lock duration.

Impact

Users could join the prize pool before awards and leave immediately without penalty, which harms the protocol's economics.

What the attacker needed

A user account with a deposit in the PrizePool

The fix

The unlock timestamp should be increased by the lock duration each time, rather than being reset.

How it was found

  1. Call withdrawWithTimelockFrom with the user's entire balance to set a timelock.
  2. Call withdrawWithTimelockFrom again with amount zero to reset the unlock timestamp to the current time.
  3. The full balance is then transferred out immediately.

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 timelock is a delay before you can withdraw money. The bug let someone skip that delay by making two withdrawals in a row: the second one reset the timer to zero, so the money could be taken out right away.

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 cmichel

View all

196 more disclosed reports, best first.

More from PoolTogether

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.