DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

Misinput in `FjordStaking::unstakeAll`

Summary

Wrong input of continue in FjordStaking::unstakeAll instead of break.

Vulnerability Details

function unstakeAll() external checkEpochRollover redeemPendingRewards returns (uint256 totalStakedAmount) {
...;
for (uint16 i = 0; i < activeDeposits.length; i++) {
uint16 epoch = uint16(activeDeposits[i]);
DepositReceipt storage dr = deposits[msg.sender][epoch];
@> if (dr.epoch == 0 || currentEpoch - epoch <= lockCycle) continue;
totalStakedAmount += dr.staked;
...;

FjordStaking::unstakeAll above is allowing user to unstake even though currentEpoch - epoch <= lockCycle will results to user staked for only below or equal with 6 epochs.

This allows for user to stake for 1 epoch then unstake to claim the reward.

Impact

User is able to unstake even before the lock cycle ends which is 6 days. This breaks the invariant where staked tokens should be locked for 6 weeks(6 epochs) and can be unstaked after that.

Tools Used

Manual Review

Recommendations

function unstakeAll() external checkEpochRollover redeemPendingRewards returns (uint256 totalStakedAmount) {
...;
for (uint16 i = 0; i < activeDeposits.length; i++) {
uint16 epoch = uint16(activeDeposits[i]);
DepositReceipt storage dr = deposits[msg.sender][epoch];
- if (dr.epoch == 0 || currentEpoch - epoch <= lockCycle) continue;
+ if (dr.epoch == 0 || currentEpoch - epoch <= lockCycle) break;
totalStakedAmount += dr.staked;
...;
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.