coolDown & warmUp period do not work when a low _firstEpochEndTime is passed to initialize
The staking contract's constructor did not check that the first epoch end time was in the future, so a very low or zero value could be passed. An attacker could then call rebase repeatedly to push the epoch number forward and bypass the warm-up and cool-down waiting periods before claiming or withdrawing.
Submitted by Lambda
In the constructor of Staking.sol, it is not enforced that the _firstEpochEndTime is larger than the current block.timestamp. If a low value is accidentally passed (or even 0), rebase can be called multiple times in sucession, causing the epoch.number to increase. Therefore, the coolDown & warmUp period can be circumvented in such a scenario, as epoch.number >= info.expiry (in _isClaimAvailable and _isClaimWithdrawAvailable) will return true after rebase caused several increases of epoch.number.
Recommended Mitigation Steps
Either require that _firstEpochEndTime is larger than block.timestamp or set the expiry of the first epoch to block.timestamp + _epochDuration.
toshiSat (Yieldy) acknowledged and commented:
This is something we thought about and will most likely set the period temporarily 1 higher when launching with low initial epoch durations.
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 constructor accepted any `_firstEpochEndTime` without validating it against the current block timestamp, letting rebase advance the epoch counter rapidly.
Impact
The warm-up and cool-down periods could be circumvented, allowing claims and withdrawals earlier than intended; the text frames this as depending on a low first epoch end time being configured.
What the attacker needed
First epoch end time set low or zero; attacker can call rebase repeatedly
The fix
The constructor should require the first epoch end time to be greater than the current block timestamp, or set the first epoch's expiry to the current time plus the epoch duration.
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 staking contract makes people wait a set number of epochs before they can claim or withdraw, to discourage quick in-and-out behaviour. The first epoch's end time was set without checking it was in the future, so if it was very small or zero, someone could trigger the epoch counter to jump ahead many times in a row. That made the waiting periods pass instantly, defeating the protection.
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.