Rebases can be frontrun with very little token downtime even when warmUpPeriod > 0
A user can stake just before an epoch ends, bypassing the forced rebase in the stake function, then immediately unstake in the next block to collect the rebase rewards without staying staked. This allows the user to get in, collect the rebase, and get out with minimal token downtime.
Submitted by 0x52, also found by elprofesor
Rebases can be frontrun with very little token downtime even when warmUpPeriod > 0.
Proof of Concept
A user can call stake the block before epoch.endTime <= block.timestamp, allowing the user to bypass the forced rebase called in L416 of the the stake function. If warmUpPeriod > 0 then the user will receive a “warmUpInfo” with the value of their deposit. The very next block, the user can then call instantUnstakeCurve.
This will call rebase again in L633 and this time epoch.endTime <= block.timestamp will be true and it will trigger an actual rebase, distributing the pending rewards. _retrieveBalanceFromUser (L617) will then allows the user to unstake all the funds locked in warm up. The issue is that when unstaking it uses userWarmInfo.credits meaning that any rebalance rewards are kept. This allows the user to get in, collect the rebase, then immediately get out.
Recommended Mitigation Steps
Being able to unstake tokens even when in the warm up period is a useful feature but tokens unstaked during that period should not be allowed to accumulate any rebases or it can lead to situations like this. L537-L539 should be changed to: warmUpBalance = userWarmInfo.amount.
toshiSat (Yieldy) acknowledged
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 unstaking logic uses the warm-up credits amount, which includes pending rebase rewards, instead of the original deposited amount, allowing rewards to be collected without proper warm-up.
What the attacker needed
WarmUpPeriod > 0; ability to stake and unstake
The fix
The warm-up balance should be set to the original deposited amount, not the credits amount, so that tokens unstaked during warm-up do not accumulate rebases.
How it was found
- Call stake in the block before epoch.endTime <= block.timestamp, bypassing the forced rebase.
- Receive a warmUpInfo with the deposit amount if warmUpPeriod > 0.
- In the next block, call instantUnstakeCurve, which triggers a rebase and distributes pending rewards.
- Unstake all funds locked in warm up, keeping the rebase rewards.
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 rebase is a reward distribution that increases token balances. The staking contract normally forces a rebase when you stake, but by timing the stake just before the epoch ends, the user avoids that forced rebase. Then, in the next block, they unstake and trigger the rebase, keeping the rewards even though they were only staked briefly.
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.