This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
robertodf - MlumStaking::addToPosition
should assing the amount multiplier based on the new lock duration instead of initial lock duration.
#138
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
Comments
github-actions
bot
added
Medium
A Medium severity issue.
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
labels
Jul 21, 2024
This was referenced Jul 21, 2024
sherlock-admin3
added
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
labels
Jul 22, 2024
This issue causes users to keep the same multiplier by reducing lock times, thus gaining an advantage. This creates an unfair advantage in the system and undermines the reliability of the staking mechanism. |
PR: #138 For scenario 1: it is a design choice that the amount mutliplier stays the same even lock duration ended. |
This was referenced Jul 25, 2024
Closed
The protocol team fixed this issue in the following PRs/commits: |
sherlock-admin4
changed the title
Slow Sapphire Barracuda -
robertodf - Jul 29, 2024
MlumStaking::addToPosition
should assing the amount multiplier based on the new lock duration instead of initial lock duration.MlumStaking::addToPosition
should assing the amount multiplier based on the new lock duration instead of initial lock duration.
The Lead Senior Watson signed off on the fix. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
robertodf
Medium
MlumStaking::addToPosition
should assing the amount multiplier based on the new lock duration instead of initial lock duration.Summary
There are two separate issues that make necessary to assign the multiplier based on the new lock duration:
First, when users add tokens to their position via
MlumStaking::addToPosition
, the new remaining time for the lock duration is recalculated as the amount-weighted lock duration. However, when the remaining time for an existing deposit is 0, this term is omitted, allowing users to retain the same amount multiplier with a reduced lock time. Consider the following sequence of actions:Alice creates a position by calling
MlumStaking::createPosition
depositing 1 ether and a lock time of 365 daysAfter the 365 days elapse, Alice adds another 1 ether to her position. The snippet below illustrates how the new lock time for the position is calculated:
The result will be:
(0*1 ether + 1 ether*365 days)/ 2 ether
, therefore Alice will need to wait just half a year, while the multiplier remains unchanged.Second, the missalignment between this function and
MlumStaking::renewLockPosition
creates an arbitrage opportunity for users, allowing them to reassign the lock multiplier to the initial duration if it is more beneficial. Consider the following scenario:MlumStaking::renewLockPosition
. The new amount multiplier will be calculated as ≈1+90/365*2 < 3
.Vulnerability Detail
Impact
You may find below the coded PoC corresponding to each of the aforementioned scenarios:
See PoC for scenario 1
Place in `MlumStaking.t.sol`.See PoC for scenario 2
Place in `MlumStaking.t.sol`.Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L409-L417
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L509-L514
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L714
Tool used
Manual Review
Recommendation
Assign new multiplier in
MlumStaking::addToPosition
based on lock duration rather than initial lock duration.The text was updated successfully, but these errors were encountered: