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

User can't unstake immediately in same epoch

Summary

When _epoch is same as current epoch, user can't unstake immediately due to underflow in the unstake function

Vulnerability Details

As per design of the protocol unstake feature, user are allowed to unstake immediately when _epoch they want to unstake is same as the current epoch

https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L449-L494

During this process the amount passed in is subtracted from the newStaked at this point

https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L470-L476

This process would always revert due to underflow because in the checkepochRollover modifier,

https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L691-L724

newStaked is always set to 0

https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L719

Which result in the revert due to underflow in the unstake process

https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordStaking.sol#L474-L476

Impact

User can't unstake immediately in the current epoch

Tools Used

Manual review

Recommendations

A corrected logic should be implemented to allow user withdraw token when _epoch == currentEpoch

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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