You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA Medium severity issue.RewardA payout will be made for this issue
extendLockPosition function May Not Perform as Expected
Summary
When a user attempts to extend their lock position , the _lockPosition function causes them to lose their waited time from previous lock.
Vulnerability Detail
_lockPostion is used to extend or renew its lock position. The issue lies in extendLockPosition this function is used to extend its lock position , the lock position shouldn't be expired , should be greater than the current lock duration and isUnlocked() == false. When a user extends its position the startLockTime is set to currentBlockTimestamp it means that user time will reset
POC:
alice creates a position , LockDuration = 60 days.
Owner locks now its possible to LockPosition.
a voting period has started which need 90 days to vote.
skip(50 days).
alice calls extendLockPosition(1 , 90 days ).
added time 90 - 60 days i.e 30 days .
then startLockTime is set to currentBlockTimestamp.position.startLockTime = currentBlockTimestamp;
so then alice time reset to 1.
alice needs to wait whole 90 days losing her 50 days waited time.
File: MlumStaking.sol
836: function _lockPosition(
837: uint256tokenId,
838: uint256lockDuration,
839: boolresetInitial840: ) internal {
841: require(!isUnlocked(), "locks disabled");
842:
843: StakingPosition storage position = _stakingPositions[tokenId];
844:
845: // for renew only, check if new lockDuration is at least = to the remaining active duration846: uint256 endTime = position.startLockTime + position.lockDuration;
847: uint256 currentBlockTimestamp =_currentBlockTimestamp();
848: if (endTime > currentBlockTimestamp) {
849: require(
850: lockDuration >= (endTime - currentBlockTimestamp) &&851: lockDuration >0,
852: "invalid"853: );
854: }
855:
856: // for extend lock postion we reset the initial lock duration857: // we have to check that the lock duration is greater then the current858: if (resetInitial) {
859: require(lockDuration > position.initialLockDuration, "invalid");
860: position.initialLockDuration = lockDuration;
861: }
862:
863: _harvestPosition(tokenId, msg.sender);
864:
865: position.lockDuration = lockDuration;
866: position.lockMultiplier =getMultiplierByLockDuration(lockDuration);
867: position.startLockTime = currentBlockTimestamp;
868: _updateBoostMultiplierInfoAndRewardDebt(position);
869:
870: emitLockPosition(tokenId, lockDuration);
871: }
0xSmartContract
added
Medium
A Medium severity issue.
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
and removed
Excluded
Excluded by the judge without consulting the protocol or the senior
labels
Jul 28, 2024
sherlock-admin4
changed the title
Shiny Neon Kestrel - extendLockPosition function May Not Perform as Expected
karsar - extendLockPosition function May Not Perform as Expected
Jul 29, 2024
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA Medium severity issue.RewardA payout will be made for this issue
karsar
High
extendLockPosition function May Not Perform as Expected
Summary
When a user attempts to extend their lock position , the _lockPosition function causes them to lose their waited time from previous lock.
Vulnerability Detail
_lockPostion
is used to extend or renew its lock position. The issue lies inextendLockPosition
this function is used to extend its lock position ,the lock position shouldn't be expired , should be greater than the current lock duration and isUnlocked() == false
. When a user extends its position the startLockTime is set to currentBlockTimestamp it means that user time will resetPOC:
position.startLockTime = currentBlockTimestamp;
Impact
lost lock time of users.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/MlumStaking.sol#L691-L718
Tool used
Manual Review
Recommendation
Now when extending LockDuration user's initialLockDuration is set to position startLockTime and its starts from its startLockTime period.
Duplicate of #138
The text was updated successfully, but these errors were encountered: