Skip to content
Business logic Audit finding Intermediate

User can initiate withdraw for previous epoch if rebase hasn’t been called since end of epoch

The unstake function allowed users to skip the rebase call, leaving the epoch number stale. An attacker could then initiate a withdrawal that was recorded in the previous epoch, letting them withdraw funds earlier than intended.

0x52 Follow

Originally disclosed on Code4rena

Submitted by 0x52

User is able to withdraw unstaked asset sooner than they should be.

Proof of Concept

Unstake() allows the user to bypass the rebase() call by setting _trigger to false. Since rebase() is bypassed, epoch.number could potentially be stale i.e. doesn’t match the Tokemak epoch. A user could potentially call unstake() with _trigger = false immediately after an epoch has ended but expiry would be set using the stale epoch.number because it wouldn’t be updated by rebase(). This would allow the user to withdraw early before their funds were actually available in the contract because their withdrawal would be considered to be in the epoch before they actually initiated the withdrawal.

Recommended Mitigation Steps

Rebase() cannot be optional when calling unstake.

toshiSat (Yieldy) acknowledged and commented:

We use a coolDownAmount of 2 to get around this.


The original report as published on Code4rena, by 0x52. 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

Likely the unstake function allowed bypassing the rebase call, so the epoch number could be stale when calculating withdrawal expiry.

Impact

A user could withdraw their unstaked assets earlier than intended, potentially before the funds are available in the contract.

What the attacker needed

A user with unstaked assets; epoch has ended but rebase not called

The fix

The rebase call should not be optional when calling unstake, or a cooldown mechanism should be used to prevent early withdrawal.

How it was found

  1. Wait until an epoch has ended but rebase has not been called.
  2. Call unstake with _trigger set to false to skip rebase.
  3. The withdrawal expiry is set using the stale epoch number, allowing early withdrawal.

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 smart contract tracks time in epochs. Normally, a rebase function updates the current epoch. The unstake function let users skip that update, so the contract still thought it was in the old epoch. This meant a user could start a withdrawal that was treated as if it happened earlier, allowing them to get their money out before it was actually available.

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 0x52

View all

211 more disclosed reports, best first.

More from Yieldy 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.