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.
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 equivalentamountoftimelockand resets_unlockTimestamps[user] = timestamp = blockTime + lockDuration. - user calls
withdrawWithTimelockFrom(user, amount=0)again but this time withdrawing0amount. This will return alockDurationof0and thusunlockTimestamp = blockTime. The inner_mintTimelocknow resets_unlockTimestamps[user] = unlockTimestamp - As
if (timestamp <= _currentTime())is true, the full users amount is now transferred out to the user in the_sweepTimelockBalancescall.
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.
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
- Call withdrawWithTimelockFrom with the user's entire balance to set a timelock.
- Call withdrawWithTimelockFrom again with amount zero to reset the unlock timestamp to the current time.
- 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.