This repository was archived by the owner on Jan 12, 2025. It is now read-only.
Praise03 - During Emergency Unlock, User can call withdrawFromPosition to make premature withdrawals and get full rewards. #575
Labels
Non-Reward
This issue will not receive a payout
Praise03
Medium
During Emergency Unlock, User can call withdrawFromPosition to make premature withdrawals and get full rewards.
Impact
Contract loses reward tokens unfairly and user can gain reward tokens without waiting the necessary lock duration
Code Snippet
In the above POC it is demonstrated that users can gain reward tokens before their lock duration elapses in the event of an emergency unlock. The protol incorrectly assumes that the users will call the _emergencyWithdraw function during and emergency which would mean their position gets closed and they get no rewards.
However, users can call the withdrawFromPosition (or harvestPosition) and close their position prematurely and also get rewards.
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/MlumStaking.sol#L626
The isUnlocked check above allows the call to go through during emergency unlocks
A malicious user could also intentionally frontrun the owners call to put the contract into emergency mode with a stakingToken deposit and then withdraw the deposited amount + rewards in the next block.
Tool used
Manual Review
Recommendation
Consider restricting the withdrawFromPosition and harvestPosition functons from being called during emergency unlocks
The text was updated successfully, but these errors were encountered: