This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
MlumStaking#addToPosition
will cause locking user's funds more than a week as an attacker will call MlumStaking#addToPosition
to user's position at the end of locking period
#152
iamnmt
Medium
Incorrect ownership check in
MlumStaking#addToPosition
will cause locking user's funds more than a week as an attacker will callMlumStaking#addToPosition
to user's position at the end of locking periodSummary
Incorrect ownership check in
MlumStaking#addToPosition
will cause locking user's funds more than a week as the attacker will callMlumStaking#addToPosition
at the end of locking period.Vulnerability Detail
Since the check
_requireOnlyOperatorOrOwnerOf
always passeshttps://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/MlumStaking.sol#L398
An attacker can call
MlumStaking#addToPosition
to a user's position to increase its locking duration. The new locking duration is(remainingLockTime * position.amount + amountToAdd * position.initialLockDuration) / (position.amount + amountToAdd)
. At the end of a locking periodremainingLockTime
will tend to zero. To lock user's fund more than a week, the attacker will add to the position withamountToAdd
such thatRequired that
position.initialLockDuration > 7 days
. A position with largeposition.initialLockDuration
will make it cheaper for the attacker to carry out this attack.Impact
Locking user's funds in
MlumStaking
position more than a week.Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/MlumStaking.sol#L140
Tool used
Manual Review
Recommendation
Fix the
MlumStaking#_requireOnlyOperatorOrOwnerOf
functionsrc/MlumStaking.sol:140
Duplicate of #378
The text was updated successfully, but these errors were encountered: