This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
0xAnmol - Loss of reward if emergencyWithdraw
is called
#428
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Medium
A Medium severity issue.
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
0xAnmol
High
Loss of reward if
emergencyWithdraw
is calledSummary
If a staker calls the emergency withdrawal, they will lose their rewards, and the rewards will get stuck in the contract instead of being distributed to other stakers.
Vulnerability Detail
When a staker calls
MlumStaking:emergencyWithdraw
, they will receive their staked amount without accrued rewards. These reward tokens should go to the other stakers. However, they will get stuck in the contract if another staker callsharvestPosition
before an emergency withdrawal is called.POC
Here is how the flow works:
harvestPosition
to get their rewards._emergencyUnlock
due to a short-term emergency._emergencyUnlock
is then turned off again.harvestPosition
before ALICE calledemergencyWithdraw
, creating a discrepancy in the reward calculations.Here is a coded POC with the console to show how this plays out.
Paste this is
MlumStaking.t.sol
Output
Impact
Reward tokens are effectively lost when they could be used to incentivize stakers.
This should be viewed as a loss of funds, and a high severity rating is appropriate.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/MlumStaking.sol#L536
Tool used
Manual Review
Recommendation
There should be a mechanism to distribute remaining rewards to the stakers if extra funds are left due to
emergencyWithdraw
.Duplicate of #460
The text was updated successfully, but these errors were encountered: