vote function does not correctly checks if the remaining duration of a LockingPosition is greater than 14 days.
Vulnerability Detail
When a user has a LockingPosition and wants to to vote, according to docs, "the remaining lock period needs to be longer then the epoch time". However, the checks in vote function is like this :
function vote(uint256 tokenId, address[] calldata pools, uint256[] calldata deltaAmounts) external {
// ...
// check if _minimumLockTime >= initialLockDuration and it is locked
@> if (_mlumStaking.getStakingPosition(tokenId).initialLockDuration < _minimumLockTime) {
revert IVoter__InsufficientLockTime();
}
@> if (_mlumStaking.getStakingPosition(tokenId).lockDuration < _periodDuration) {
revert IVoter__InsufficientLockTime();
}
// ...
}
As we can see, the function checks if the lockDuration is greater than the _periodDuration which is 14 days. However, the lockDuration of the LockingPosition can indeed be greater than the 14 days but the remaining lock time to be actually seconds.
Impact
This vulnerability leads to someone to be actually to double vote since he can vote with a LockingPosition which has remaining lock time some seconds and then withdraw his staked MLUM and stake them again and vote again. Also, the invariant of the protocol that "the remaining lock period needs to be longer then the epoch time" is not enforced.
zarkk01
Medium
vote
function does not correctly checks if the remaining duration of aLockingPosition
is greater than 14 days.Vulnerability Detail
When a user has a
LockingPosition
and wants to to vote, according to docs, "the remaining lock period needs to be longer then the epoch time". However, the checks invote
function is like this :As we can see, the function checks if the
lockDuration
is greater than the_periodDuration
which is 14 days. However, thelockDuration
of theLockingPosition
can indeed be greater than the 14 days but the remaining lock time to be actually seconds.Impact
This vulnerability leads to someone to be actually to double vote since he can vote with a
LockingPosition
which has remaining lock time some seconds and then withdraw his staked MLUM and stake them again and vote again. Also, the invariant of the protocol that "the remaining lock period needs to be longer then the epoch time" is not enforced.Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/Voter.sol#L175
Tool used
Manual Review
Recommendation
Consider checking that the remaining lock periods is longer than 14 days by using the block.timestamp.
Duplicate of #166