This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
PUSH0 - New staking positions still gets the full reward amount as with old stakings, diluting rewards for old stakers #74
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
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
PUSH0
High
New staking positions still gets the full reward amount as with old stakings, diluting rewards for old stakers
Summary
New staking positions still gets the full reward amount as with old stakings, diluting rewards for old stakers. Furthermore, due to the way multipliers are calculated, extremely short stakings are still very effective in stealing long-term stakers' rewards.
Vulnerability Detail
In the Magic LUM Staking system, users can lock-stake MLUM in exchange for voting power, as well as a share of the protocol revenue. As per the docs:
However, when rewards are distributed, new and old staking positions are treated alike, and immediately receive the same rewards as it is distributed.
Thus, anyone can stake MLUM for a short duration as rewards are distributed, and siphon away rewards from long-term stakers. Staking for a few days still gets almost the same multiplier as staking for a year, and the profitability can be calculated and timed by calculating the protocol's revenue using various offchain methods (e.g. watching the total trade volume in each time intervals).
Consider the following scenario:
Note that expired positions, while should not be able to vote, still accrue rewards. Thus Bob can just leave the position there and withdraw whenever he wants to without watching the admin actions. A more sophisticated attack involves front-running the admin reward distribution to siphon rewards, then unstake right away.
PoC
Due to the way multipliers are calculated, 1-year lock positions are only at most 3 times stronger than a 1-second lock for the same amount of MLUM.
The following coded PoC shows the given scenario, where Bob is able to siphon 25% of the rewards away by staking for a duration of a single second and leave it there.
Paste the following test into
MlumStaking.t.sol
, and run it byforge test --match-test testPoCHarvestDilute -vv
:The test logs will be
i.e. Bob was able to siphon 25% of the rewards.
Impact
Staking rewards can be stolen from honest stakers.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L354
Tool used
Manual Review
Recommendation
When new positions are created, their position should be recorded, but their amount with multipliers should be summed up and queued until the next reward distribution.
When the admin distributes rewards, there should be a function that first updates the pool, then add the queued amounts into staking. That way, newly created positions can still vote, but they do not accrue rewards for the immediate following distribution (only the next one onwards).
The text was updated successfully, but these errors were encountered: